Solved

IE scrollbar drag and drop bug

Posted on 2006-07-13
2
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

751 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