Skip to content

Commit

Permalink
Fix #473
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Sep 4, 2023
1 parent 3f6152f commit 3b35395
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

* Fix for using `"svg"` device during knitting (#484)
* Fix for correctly getting chunk options during knitting (#485)
* Fix a bug in `transition_reveal()` that would remove terminal data (#480)
* Fix a bug in `transition_reveal()` that would remove data during transitions
(#480 and #473)
* General upkeep to keep it in line with the evolvling coding principles in
ggplot2 (move to using vctrs, cli, lifecycle, etc)
* `transition_reveal()` now throws an error when it is used in conjunction with
Expand Down
10 changes: 6 additions & 4 deletions R/transition_reveal.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ TransitionReveal <- ggproto('TransitionReveal', Transition,
)
all_frames$group <- paste0(all_frames$group, '<', all_frames$.frame, '>')
all_frames$.frame <- NULL
repeated <- c(diff(all_frames$.time), 1) <= .Machine$double.eps &
c(all_frames$group[-nrow(all_frames)] == all_frames$group[-1], TRUE) &
all_frames$.phase == 'raw'
all_frames[!repeated, ]
transitions <- setdiff(which(all_frames$.phase == "transition"), 1L)
transitions <- transitions[all_frames$.phase[transitions-1L] == "raw" & all_frames$group[transitions-1L] == all_frames$group[transitions]]
possible_repeats <- sort(c(transitions, transitions - 1L))
repeated <- duplicated(all_frames[possible_repeats, names(all_frames) != '.phase'], fromLast = TRUE)
repeated <- possible_repeats[repeated]
if (length(repeated) == 0) all_frames else all_frames[-repeated, ]
}
)

Expand Down

0 comments on commit 3b35395

Please sign in to comment.