Jump to content

Drag Div


MarcB
 Share

Recommended Posts

Hi

I'm struggling over an issue with the drag and drop script explained here: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_draggable.

When the drag element is moved outside the browser and the mousebutton is released, the element will stick to the cursor when returning to the window and it's impossible to release it.

It works fine on this site: https://www.w3schools.com/howto/howto_js_draggable.asp, probably cause it's nested inside an iframe.(?)

It's not an issue when the default behaviour of the browser is not prevented.  But deleting the e.preventDefault() brings me a couple of other issues (selection, browser cursor).

Any suggestions?

 

Thx Marc

Edited by MarcB
Link to comment
Share on other sites

... after a couple of hours I decided to just go with the default browser behaviour and deleted the preventDefault() commands.

Now I'm adding a css class-list to the body (user-select:none ... plus prefixes) on mousedown, deleting this class on mouseup. 

Edited by MarcB
Link to comment
Share on other sites

I've only tested the script offline so far, I've now found out that the browser behavior described above does not occur online ...

So everything allright with e.preventDefault().

Sorry for spamming, this topic may be deleted.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...