Skip to content

Commit

Permalink
fix: fix bug of effect
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeX4 committed Dec 18, 2024
1 parent e54003c commit f56991b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/configs.typ
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@
/// - uncover (function): The function to uncover content. The default value is `utils.uncover` function.
///
/// - only (function): The function to show only the content. The default value is `utils.only` function.
///
/// - effect (function): The function to add effect to the content. The default value is `utils.effect`.
///
/// - alternatives-match (function): The function to match alternatives. The default value is `utils.alternatives-match` function.
///
Expand All @@ -358,6 +360,7 @@
// dynamic control
uncover: _default,
only: _default,
effect: _default,
alternatives-match: _default,
alternatives: _default,
alternatives-fn: _default,
Expand All @@ -377,6 +380,7 @@
cover: cover,
uncover: uncover,
only: only,
effect: effect,
alternatives-match: alternatives-match,
alternatives: alternatives,
alternatives-fn: alternatives-fn,
Expand Down Expand Up @@ -656,6 +660,7 @@
// dynamic control
uncover: utils.uncover,
only: utils.only,
effect: utils.effect,
alternatives-match: utils.alternatives-match,
alternatives: utils.alternatives,
alternatives-fn: utils.alternatives-fn,
Expand Down
2 changes: 1 addition & 1 deletion src/core.typ
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@
/// - cont (content): The content to display when the content is visible in the subslide.
///
/// - is-method (boolean): A boolean indicating whether the function is a method function. Default is `false`.
#let effect(visible-subslides, fn, cont, is-method: false) = {
#let effect(fn, visible-subslides, cont, is-method: false) = {
touying-fn-wrapper(
if is-method {
fn
Expand Down
32 changes: 32 additions & 0 deletions src/utils.typ
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,38 @@
}
}

/// Take effect in some subslides.
///
/// Example: `#effect(text.with(fill: red), "2-")[Something]` will display `[Something]` if the current slide is 2 or later.
///
/// You can also add an abbreviation by using `#let effect-red = effect.with(text.with(fill: red))` for your own effects.
///
/// - visible-subslides (int, array, string): `visible-subslides` is a single integer, an array of integers,
/// or a string that specifies the visible subslides
///
/// Read [polylux book](https://polylux.dev/book/dynamic/complex.html)
///
/// The simplest extension is to use an array, such as `(1, 2, 4)` indicating that
/// slides 1, 2, and 4 are visible. This is equivalent to the string `"1, 2, 4"`.
///
/// You can also use more convenient and complex strings to specify visible slides.
///
/// For example, "-2, 4, 6-8, 10-" means slides 1, 2, 4, 6, 7, 8, 10, and slides after 10 are visible.
///
/// - fn (function): The function that will be called in the subslide.
/// Or you can use a method function like `(self: none) => { .. }`.
///
/// - cont (content): The content to display when the content is visible in the subslide.
///
/// - is-method (boolean): A boolean indicating whether the function is a method function. Default is `false`.
#let effect(self: none, fn, visible-subslides, cont) = {
if check-visible(self.subslide, visible-subslides) {
fn(cont)
} else {
cont
}
}

/// Uncover content in some subslides. Reserved space when hidden (like `#hide()`).
///
/// Example: `uncover("2-")[abc]` will display `[abc]` if the current slide is 2 or later
Expand Down

0 comments on commit f56991b

Please sign in to comment.