qmd-lab / closeread

https://closeread.dev
MIT License
130 stars 5 forks source link

Add permutation test demo #46

Open andrewpbray opened 4 months ago

andrewpbray commented 4 months ago

This attempts to add a quarto version of a well-done scrolly that features some very custom js graphics. Right now the html file has been run through pandoc to create md source and first efforts have been made to include some of the js via ojs code cells.

There are a few puzzles that I haven't figured out yet:

Also, the author of this piece, Jared Wilbur has given permission to include this example. He has also done some awesome work that incorporates Svelte: https://mlu-explain.github.io/linear-regression/

andrewpbray commented 4 months ago

The key functionality that we'd be translating into quarto syntax is the following js:

if (response.index == 0 & response.direction == 'down') {
  transitionZeroDown()
} else if (response.index == 0 & response.direction == 'up') {
  transitionZeroUp()
} else if (response.index == 1 & response.direction == 'down') {
  transitionOneDown()
} else if (response.index == 1 & response.direction == 'up') {
  transitionOneUp()
\\ and so on to transitionEightUp()

So he calls a specific function on every combination of step and direction. Would something like the following work?

:::{focus-on="alpacas" runjs-if-down="transitionOneDown runjs-if-up="transitionOneUp"}
Text of the step
:::