1

All I m using the below code snippet to make a pop draggable. the issue im facing is scroll bar is not being detected, the pop up moves instead of scroll. I did see some similar questions, but the implementation seems to be different in their case, Can you help?

$('#Div1').mousedown(function(ev) { divToMove = document.getElementById('Div1'); var divName = '#Div1'; dragHandler(ev,divName); }); function dragHandler(e,divName){ var offSet = $(divName).position(); dragOK = true; dragXoffset = e.clientX - offSet.left; dragYoffset = e.clientY - offSet.top; $(divName).mousemove(function(ev){ moveHandler(ev) }); $(divName).mouseup(function(ev){ cleanup(ev, divName) }); return false; } function cleanup(e, divName) { $(divName).mousemove = null; $(divName).mouseup = null; dragOK = false; } function moveHandler(e) { if (e == null) { e = window.event } if (e.button <= 1 && dragOK) { divToMove.style.left = e.clientX - dragXoffset + 'px'; divToMove.style.top = e.clientY - dragYoffset + 'px'; return false; } } 

Please see this example in js fiddle. The issue doesnt happen in chrome, happens only in IE and ff. http://jsfiddle.net/6g6Xr/74/

3
  • Can you supply the complete example on jsfiddle? jsfiddle.net Commented Nov 26, 2013 at 7:03
  • I think you have 2 give height and width so that scroll bars will appear. Try adding fixed height and width. Commented Nov 26, 2013 at 9:10
  • Hi stackoverflow.com/users/2837813/progm, i have added the xample in js fiddle, can u plz take a look, issue present only in ie and ff. Commented Nov 26, 2013 at 10:11

1 Answer 1

1
+50

I was wanting to comment but do not have enough points. I see you have included jQuery UI in the jsfiddle, is it possible to use its draggable component if you are using UI already? If so you could use the handle property shown here in the second part of this answer: https://stackoverflow.com/a/8793280/2603735

jQuery UI handle reference

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.