Преглед изворни кода

Give enter/exit options name of expression used

ggproto objects like those created by enter_fade() or exit_appear() evaluate to enviroments making it impossible to compare two ggproto objects to determine if they are the same (both will be different environments). To get around this, I store the expression used to create the enter/exit arguments so that we can later compare two objects created by anim_options().
pkg-add-anim-opts-fixed
Garrick Aden-Buie пре 7 година
родитељ
комит
707fa062f5
1 измењених фајлова са 7 додато и 4 уклоњено
  1. +7
    -4
      R/plot_helpers.R

+ 7
- 4
R/plot_helpers.R Прегледај датотеку

title_size = NULL, title_size = NULL,
... ...
){ ){
enter_name <- rlang::quo_name(rlang::enquo(enter))
exit_name <- rlang::quo_name(rlang::enquo(exit))
structure( structure(
list( list(
transition_length = transition_length, transition_length = transition_length,
state_length = state_length, state_length = state_length,
ease_default = ease_default, ease_default = ease_default,
ease_other = ease_other, ease_other = ease_other,
enter = enter,
exit = exit,
enter = setNames(list(enter), enter_name),
exit = setNames(list(exit), exit_name),
text_family = text_family, text_family = text_family,
text_size = text_size, text_size = text_size,
title_family = title_family, title_family = title_family,
if (!inherits(ao, "anim_opts")) { if (!inherits(ao, "anim_opts")) {
rlang::warn("Use `anim_options()` to set `anim_opts`") rlang::warn("Use `anim_options()` to set `anim_opts`")
} }
stopifnot(is.ggproto(ao$enter[[1]]), is.ggproto(ao$exit[[1]]))
extra_names <- setdiff(names(ao), names(formals(anim_options))) extra_names <- setdiff(names(ao), names(formals(anim_options)))
if (!quiet && length(extra_names)) { if (!quiet && length(extra_names)) {
extra_names <- paste0(sprintf("`%s`", extra_names), collapse = ", ") extra_names <- paste0(sprintf("`%s`", extra_names), collapse = ", ")


static_plot(d, title, anim_opts = ao) + static_plot(d, title, anim_opts = ao) +
transition_states(.frame, ao$transition_length, ao$state_length) + transition_states(.frame, ao$transition_length, ao$state_length) +
ao$enter +
ao$exit +
ao$enter[[1]] +
ao$exit[[1]] +
ao_ease_aes ao_ease_aes
} }



Loading…
Откажи
Сачувај