Skip to content

PlutoUI.Scrubbable doesn't render #154

@alecloudenback

Description

@alecloudenback

It seems like scrubbable elements don't render in the static version, though there remains a script embedded where there should be something displayed.

Example (should read "With probability equal to 90% that the Observed Rate..." :
image

Served page: https://juliaactuary.org/tutorials/credibility_claims/
Source Franklin site and notebook: https://github.com/JuliaActuary/JuliaActuary.org/blob/54bf2cc5724aa7c7a5fc5f7173fc17c34117f931/tutorials/credibility_claims.jl

Note that I've subsequently pushed a commit to the notebook removing Scrubbable elements, but the repository permalink should still point to the version which had Scrubbables which did not render.

Here's the script contents from the screenshot:

 // weird import to make it faster. The `await import` can still delay execution by one frame if it is already loaded... window.d3format = window.d3format ?? await import("https://cdn.jsdelivr.net/npm/d3-format@2/+esm") const argmin = xs => xs.indexOf(Math.min(...xs)) const closest_index = (xs, y) => argmin(xs.map(x => Math.abs(x-y))) const values = [0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99] const el = html` <span title="Click and drag this number left or right!" style="cursor: col-resize; touch-action: none; background: rgb(252, 209, 204); color: black; padding: 0em .2em; border-radius: .3em; font-weight: bold;">0.9</span> ` let old_x = 0 let old_index = 0 const initial_index = closest_index(values, 0.9) let current_index = initial_index const formatter = s => "" + d3format.format(".0%")(s) + "" Object.defineProperty(el, 'value', { get: () => values[current_index], set: x => { current_index = closest_index(values, x) el.innerText = formatter(el.value) }, configurable: true, }); // initial value el.innerText = formatter(0.9) const onScrub = (e) => { const offset = e.clientX - old_x const new_index = Math.min(values.length-1, Math.max(0, Math.round(offset/10) + old_index )) if(new_index !== current_index) { current_index = new_index el.innerText = formatter(el.value) el.dispatchEvent(new CustomEvent("input")) } } const onpointerdown = (e) => { window.getSelection().empty() old_x = e.clientX old_index = current_index window.addEventListener("pointermove", onScrub) } el.addEventListener("pointerdown", onpointerdown) const ondblclick = (e) => { current_index = initial_index el.innerText = formatter(el.value) el.dispatchEvent(new CustomEvent("input")) } el.addEventListener("dblclick", ondblclick) const onpointerup = () => { window.removeEventListener("pointermove", onScrub) } window.addEventListener("pointerup", onpointerup) el.onselectstart = () => false invalidation.then(() => { el.removeEventListener("pointerdown", onpointerdown) el.removeEventListener("dblclick", ondblclick) window.removeEventListener("pointerup", onpointerup) }) return el 

I tried running this manually in the console, and it returned undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions