-
Notifications
You must be signed in to change notification settings - Fork 6
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
Plots.jl click fails #4
Comments
What could get wrong in this chunk of code? HTML("""<script id="hello">
const body = $(PlutoRunner.publish_to_js(plot_render))
const mime = "image/svg+xml"
const img = this ?? document.createElement("img")
let url = URL.createObjectURL(new Blob([body], { type: mime }))
img.type = mime
img.src = url
img.draggable = false
const clamp = (x,a,b) => Math.min(Math.max(x, a), b)
img.transform = f => [
clamp(f[0] * $(r.x_scale) + $(r.x_offset), $(r.x_min), $(r.x_max)),
clamp(f[1] * $(r.y_scale) + $(r.y_offset), $(r.y_min), $(r.y_max)),
]
img.fired = false
const val = {current: undefined }
# if(this == null) {
# Object.defineProperty(img, "value", {
# get: () => val.current,
# set: () => {},
# })
# const handle_mouse = (e) => {
# const svgrect = img.getBoundingClientRect()
# const f = [
# (e.clientX - svgrect.left) / svgrect.width,
# (e.clientY - svgrect.top) / svgrect.height
# ]
# console.log(f)
# if(img.fired === false){
# img.fired = true
# val.current = img.transform(f)
# img.dispatchEvent(new CustomEvent("input"), {})
# }
# }
# img.addEventListener("click", onclick)
# img.addEventListener("pointerdown", e => {
# if($(draggable)){
# img.addEventListener("pointermove", handle_mouse);
# }
# handle_mouse(e);
# });
# const mouseup = e => {
# console.log(e)
# img.removeEventListener("pointermove", handle_mouse);
# };
# document.addEventListener("pointerup", mouseup);
# document.addEventListener("pointerleave", mouseup);
# }
return img
</script>""") somehow |
@mmikhasenko Did you get an error in the chrome dev tools? (Is it because you used |
I run Pluto in Chrome on Windows. I did not use dev tools for anything in this notebook. What do you mean exactly? |
Take a look at https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Tools_and_setup/What_are_browser_developer_tools . Also make sure that you read through https://featured.plutojl.org/web/javascript , understanding this notebook will save you a lot of time! |
Thanks for the links, I educated myself about JavaScript a little bit.
There are no errors in the DevTools, when JavaScript is executed. A cell with plotclicktracker(linepoint([5,5])) works. The coordinate values Btw, there are errors that are present in all notebooks |
(Those extra errors are probably because of a chrome extension, click on the source (commons.js) to find out) |
@mmikhasenko Could you share a short notebook that demonstrates what works, and what doesn't work? You used Julia comments ( |
no, sorry, ignore the Can try now with bing |
Okay! But could you please make a single notebook file that demonstrates what works (#4 (comment) ) and what doesn't? |
Same Julia error with Microsoft Bing
|
https://gist.github.com/mmikhasenko/9ab5fbe4e9abd28057b44a15e31e0b6e#file-plotclicktracker-drag-jl |
Just made the code work by replacing
by
in the javascript. |
@fonsp do you see the same twinkles? |
Please check https://fonsp.com/disorganised-mess/plotclicktracker%20drag.html
breaks for me in very first cell with
The text was updated successfully, but these errors were encountered: