Kaynağa Gözat

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().
pull/18/head
Garrick Aden-Buie 7 yıl önce
ebeveyn
işleme
aa22ee1264
1 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  1. +7
    -4
      R/plot_helpers.R

+ 7
- 4
R/plot_helpers.R Dosyayı Görüntüle

@@ -32,14 +32,16 @@ anim_options <- function(
title_size = NULL,
...
){
enter_name <- rlang::quo_name(rlang::enquo(enter))
exit_name <- rlang::quo_name(rlang::enquo(exit))
structure(
list(
transition_length = transition_length,
state_length = state_length,
ease_default = ease_default,
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_size = text_size,
title_family = title_family,
@@ -54,6 +56,7 @@ validate_anim_opts <- function(ao, quiet = FALSE, strict = getOption("tidyexplai
if (!inherits(ao, "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)))
if (!quiet && length(extra_names)) {
extra_names <- paste0(sprintf("`%s`", extra_names), collapse = ", ")
@@ -87,8 +90,8 @@ animate_plot <- function(

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


Yükleniyor…
İptal
Kaydet