r/javascript • u/monica_b1998 • Jul 13 '19
A silly contraption using a physics engine
http://slicker.me/javascript/physics_experiment.htm0
Jul 13 '19
[deleted]
3
u/monica_b1998 Jul 13 '19
you would have to use 'ontouchstart' instead of 'onclick' in line 47. iphone does not support 'pointerdown' :(
0
Jul 13 '19
[deleted]
3
1
u/PalestineFacts Jul 14 '19
worked on my android
2
u/monica_b1998 Jul 14 '19
ok, i'll fix the tutorial tomorrow. it turns out window.onclick works on Android touchscreens, but on iPhone you have to tie the event listener to a 'clickable' object (eg. the canvas), not the window object...
2
u/PalestineFacts Jul 14 '19
Interesting, thanks for sharing
1
u/monica_b1998 Jul 14 '19
yep, adding the listener to the canvas instead of the window did the trick. the tutorial is now working on iphones as well
2
u/d07RiV Jul 15 '19
Does it work in Chrome? Or is it somehow specific to iOS and not the browser?
1
u/monica_b1998 Jul 16 '19
it should now work in all browsers (except lynx) with mouse or touchscreen
3
2
u/bullevard Jul 13 '19
That was oddly satisfying. Thanks for sharing.