Skip to content

Commit f5ef209

Browse files
committed
Update docs
1 parent cabc299 commit f5ef209

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

Diff for: docs/syntax.rst

+29-5
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,25 @@ These attributes are actions that will be executed when a ``pause`` or ``step``
168168
Moves the screen untils the element is centered.
169169

170170
``focus`` or ``focus-at-unpause``
171-
Focus on the element by zooming on it.
171+
Focus on the element by zooming on it. Possible to specify multiple ids.
172172

173173
``unfocus`` or ``unfocus-at-unpause``
174174
Unfocus by going back to the last position before a focus.
175175

176176
``static-at-unpause``
177-
Make the element ``static``. By "static" we mean the css styling ``position:static; visibility:visible`` will be applied.
177+
Make the element ``static``. By "static" we mean the css styling ``position:static; visibility:visible`` will be applied. Possible to specify multiple ids.
178178

179179
``unstatic-at-unpause``
180-
Make the element ``unstatic``. By "unstatic" we mean the css styling ``position:absolute; visibility:hidden`` will be applied.
180+
Make the element ``unstatic``. By "unstatic" we mean the css styling ``position:absolute; visibility:hidden`` will be applied. Possible to specify multiple ids.
181181

182182
``reveal-at-unpause``
183-
Reveal the element. By "revealing" we mean the css styling ``opacity:1`` will be applied.
183+
Reveal the element. By "revealing" we mean the css styling ``opacity:1`` will be applied. Possible to specify multiple ids.
184+
185+
``unreveal-at-unpause``
186+
Hide the element. By "unrevealing" we mean the css styling ``opacity:0`` will be applied. Possible to specify multiple ids.
184187

185188
``exec-at-unpause``
186-
Execute the slipscript.
189+
Execute the slipscript. Possible to specify multiple ids.
187190

188191
Custom scripts
189192
--------------
@@ -200,3 +203,24 @@ Use a slipscript code block to add a script, and ``exec-at-unpause`` to execute
200203
return {undo : () => { elem.style.opacity = old_value }}
201204
```
202205
206+
Beware: experimental! Slip-scripts have access to a ``slip`` object, which they can use to programmatically call the functions above. Using such API registers an undo callback, and it is not needed to return an undo function.
207+
208+
.. code-block:: markdown
209+
210+
{exec-at-unpause}
211+
```slip-script
212+
let elem = document.querySelector("#id")
213+
slip.up(elem);
214+
```
215+
216+
Note that if a function above accepts multiple IDs (as ``unstatic-at-unpause`` for instance), then the function expects a list of elements:
217+
218+
.. code-block:: markdown
219+
220+
{exec-at-unpause}
221+
```slip-script
222+
let elems = document.querySelectorAll(".class")
223+
slip.unstatic(elems);
224+
```
225+
226+
In addition to the function above, you can use ``slip.setStyle(elem, style, value)`` where ``elem`` is an element, and ``style`` and ``value`` a string to set a style and register an undo callback. You can also use ``slip.setClass(elem, className, bool)`` where ``elem`` is an element, ``style`` is a string and ``bool`` a boolean to add or remove a class and register an undo callback.

0 commit comments

Comments
 (0)