-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Sliders! #109
New Sliders! #109
Conversation
Great! Some short comments based on reading the code:
|
I have undid the changes so that it is now Let me elaborate a bit more on the overwriting the div valuesetter. Observe the sample notebook on Javascript, if you create two cells saying
when you observe Object.defineProperty(div, "value",
{configurable: false, enumerable: false,
get: () => {return count},
set: (newVal) => {
count = newVal
}}) would cause the individual click counters to update the local variable when the outer div's value property gets set. |
src/Builtins.jl
Outdated
|
||
slider.addEventListener("input", e => { | ||
parentnode.value = +slider.value | ||
$(JavaScript(show_value ? "parentnode.querySelector(\"output\").value = +slider.value" : "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of generating JS like this, can you add line 34:
let show_value = $(show_value)
and then use normal JS in this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for I feel that doing so is superior is two-fold:
- This minimizes the javascript on the page being rendered. When one attempts to study the Pluto cells, it is easier to understand if we provide less code in the first place, rather than having a bunch of objects in the page and hiding their visibility on the browser. Here, we minimized the code sent between the server and the client.
- The pedagogical advantage of showing an example where we interpolate javascript code using Julia is very useful in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to linger on this point but 1. is not a necessary optimization, and I see 2. exactly opposite: I don't want to teach this code style to people, so we shouldn't use it ourselves.
Implemented in #148 , thanks for thinking together! |
This reimplements Sliders solving two issues:
HypertextLiteral.jl
as stated in [WIP] refactoring PlutoUI with Mustache #62 and Rewrite to use Hyperscript.jl #59 .show_value = true
, moving a Slider would only change the display of the various input ranges, but not the display of the value. This syncs all the values, solving @bind doesn't update showed value for multiple instances in different cells #96 .Unfortunately, there is a slight caveat to consider. Traditionally, the Slider is seen as the "simplest" example of PlutoUI and a good way to introduce the ecosystem. However, this rewrite makes use of fairly nasty tricks to ensure (2) above.