Jump to content

Recommended Posts

Hi fellow php-freaks,

 

This is my first post, I wonder if anyone could offer some assisstance.

 

I've written a drag and drop script. onmousedown, checks that the target is draggable, if it is, it sets document.onmousemove = startDrag(), onmouseup if we are dragging and we are over a dropbox fires off to PHP on server to store current dropped items.

 

This all works perfectly (the way I want it). My issue is that when dragging the div it highlights elements on the page, such as other draggable items and paragraphs etc.

 

Would anyone have any idea why highlighting would be occurring, or how i could stop it from highlighting?

 

I can provide more information if there isn't enough here to answer my query.

 

Thanks

Derranga

Link to comment
https://forums.phpfreaks.com/topic/73499-solved-drag-and-drop/
Share on other sites

I know very little javascript, so i'm going to have to go with logic here, don't ask me if I can provide code - because I don't know how to code in javascript - i'm only trouble shooting the logic behind what you described:

 

First I would find the function that highlights the dragable areas. This function undoubtedly is enabled by onmouseover. I would change this to only be activated when the onmouseup is activated (meaning the user dropped the draggable item.) My best guess would be to add if(!document.onmousedown) { //highlight the draggable items, otherwise do nothing.

 

Again, I suck at javascript, so forgive me if my syntax is wrong :P.

 

 

Link to comment
https://forums.phpfreaks.com/topic/73499-solved-drag-and-drop/#findComment-370775
Share on other sites

Yzerman,

 

not sure about this, is it possible to stop the browser from highlighting while mousedown? If so and anyone knows how to stop it, please do tell.

 

Many thanks

You need to overload onselectstart...

 

okay, and you just set it it to a function that returns nothing?

but what about mozilla, and opera, i don't think they support that property yet do they?

Link to comment
https://forums.phpfreaks.com/topic/73499-solved-drag-and-drop/#findComment-370928
Share on other sites

Solved it !!

 

if you use the javascript onselectstart for ie

and for mozilla put in your CSS class:

-moz-user-select: none;

 

and no more selecting!! although in ie it's more than possible to turn off javascript, mozilla is a little harder to get around. If you're reading this entire post then you'll know i'm using javascript for my drag n drop and if they turn off js then who gives a cr*p  :P

 

Thanks PHP-freaks

Link to comment
https://forums.phpfreaks.com/topic/73499-solved-drag-and-drop/#findComment-370938
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.