浏览代码

Export print and is methods for anim_opts

And no need to filter out NULL elements
pkg-add-anim-opts-fixed
父节点
当前提交
bbb8410c78
共有 2 个文件被更改,包括 10 次插入7 次删除
  1. +2
    -0
      NAMESPACE
  2. +8
    -7
      R/animate_options.R

+ 2
- 0
NAMESPACE 查看文件

@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(print,anim_opts)
export("%>%")
export(anim_options)
export(anim_options_set)
@@ -16,6 +17,7 @@ export(animate_spread)
export(animate_union)
export(animate_union_all)
export(get_font_size)
export(is.anim_opts)
export(set_font_size)
importFrom(dplyr,anti_join)
importFrom(dplyr,arrange)

+ 8
- 7
R/animate_options.R 查看文件

@@ -79,18 +79,19 @@ get_anim_opt <- function(anim_opt = NULL) {

# Animation Options Methods -----------------------------------------------

print.anim_opts <- function(ao, full = FALSE) {
if (!full) ao <- purrr::discard(ao, is.null)
#' @export
print.anim_opts <- function(x) {
# Replace ggproto (enter/exit functions) with their names
if ("enter" %in% names(ao)) ao$enter <- paste("ggproto:", names(ao$enter))
if ("exit" %in% names(ao)) ao$exit <- paste("ggproto:", names(ao$exit))
x <- capture.output(str(ao, no.list = TRUE))
if ("enter" %in% names(x)) x$enter <- paste("ggproto:", names(x$enter))
if ("exit" %in% names(x)) x$exit <- paste("ggproto:", names(x$exit))
anim_opts <- capture.output(str(x, no.list = TRUE))
cat(
paste0("<anim_options: ", length(ao), " options>"),
x, sep = "\n"
paste0("<anim_options: ", length(x), " options>"),
anim_opts, sep = "\n"
)
}

#' @export
is.anim_opts <- function(ao) inherits(ao, "anim_opts")



正在加载...
取消
保存