I'm working on a little script that makes an object (div or img) moveable and zoomable within a given frame.
However I came across a few problems I'm not really sure of, because I'm a javascript beginner - so explanation of why those problems occure would be appreciated.
Problems:
- Calling the functions
start_drag()
,while_drag()
andstop_drag()
returnsundefined
- why is that? What should be returned? - The dragging and moving of the image does not work correctly - instead of clicking the mousebutton down and starting to move the image around, I have to click once and then start moving. Although I bound the
mousedown
event to the image. What did I do wrong? - Why is the moving part not working on mobile (the zooming works!)?
Please see my fiddle: https://jsfiddle.net/pow4ngbw/15/
Working fine now, was mainly the image css but found several errors (see the new img attribute), also added a few tweaks to make the dragging smoother.