Solved

IE scrollbar drag and drop bug

Posted on 2006-07-13
2
226 Views
Last Modified: 2008-03-10
I have a floating div with a onmousedown function to move it. the function sets simpy a var grabbed = true, on mouseup I set grabbed = false. Then I do simply a window.onmousemove and if grabbed is true, then I move the div to follow the pointer. Now the trouble arises if I have a scrollbar on my floating div, if I click on the bar, the onmousedown is executed (thus grabbing the div) but the mouseup is never executed, then the div is never released... the div looks like this :

<div onmousedown='grabit()' onmouseup='releaseit()' id='thediv' style='overflow:auto;height:100'>

<div>

Under firefox it works fine, the bug arises only under IE. How could I arrange this ?
0
Comment
Question by:Drakecoldwinter
2 Comments
 
LVL 2

Author Comment

by:Drakecoldwinter
ID: 17111068
Once again I answer myself trough research, test and error... I have done some code that will ignore the mousedown or up when is over the scrollbar :

var thescrollX = getLeft(document.getElementById('msgbox')) +  
                     document.getElementById('msgbox').offsetWidth - 50;
var thescrollYtop = getTop(document.getElementById('msgbox')) + 15;
var thescrollYbot = getTop(document.getElementById('msgbox')) +
                      document.getElementById('msgbox').offsetHeight - 15;

if((curX>thescrollX )&&(curX<thescrollX+20)&&(curY>thescrollYtop )&&(curY<thescrollYbot)){
                        grabbed=false;}

it is very easy, before doing the onmousedown I check if the cursor is over the scrollbars, if it is the case, I ignore the rest of the code and don't do any drag ;) of course the 50, and 15 must be adjusted for your div ;)
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 17117891
Closed, 125 points refunded.
Netminder
Site Admin
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now