Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#9379 closed bug (fixed)

Draggable: position bug in scrollable div

Reported by: pierrickrouxel Owned by: mikesherov
Priority: major Milestone: 1.11.0
Component: ui.draggable Version: 1.10.3
Keywords: regression Cc:
Blocked by: Blocking:

Description

When draggable is in scrollable div, the widget doesn't follow the mouse.

Tested with safari and chrome browsers. The bug appears in 1.10.3 version. It is not present in 1.10.2 version !

You can see the bug in this fiddle : http://jsfiddle.net/VPqBp/1/

Change History (12)

comment:1 Changed 4 years ago by tj.vantoll

Keywords: regression added
Status: newopen
Summary: Draggable position bug in scrollable divDraggable: position bug in scrollable div

This was almost certainly caused by https://github.com/jquery/jquery-ui/commit/a88d64514001867b908776e6bfcfac7f1011970d and is a duplicate of #9315. But I'll leave this open separately since this is a bit different.

comment:2 Changed 4 years ago by tj.vantoll

Reduced version of test case from tkhyn in #9315: http://jsfiddle.net/tj_vantoll/c4CDc/

This is not a duplicate as #9315 has been fixed.

comment:3 in reply to:  2 Changed 4 years ago by Thomas Khyn

Thanks tj.vantoll, that's indeed the same issue.

For the record and if it can help the future owner of the ticket, here is my comment and a temporary hack as posted on #9315.

The workaround I found is to replace

if (!this.offset.scroll) {

by

if (!this.offset.scroll || scroll.scrollTop() != this.offset.scroll.top || scroll.scrollLeft() != this.offset.scroll.left) {

in the implementations of _convertPositionTo and _generatePosition in jquery.ui.draggable.js. The execution is probably even faster if the condition is removed so that this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; is always executed.

Indeed, this.offset.scroll is never updated when the page/container is scrolled (it is only set once when dragging starts and this.offset.scroll is false). In version 1.10.2, the returned values are calculated using scroll.scrollTop() and scroll.scrollLeft() in the return statement instead of using the (fixed) values from this.offset.scroll as it is in version 1.10.3.

comment:4 Changed 4 years ago by mikesherov

Milestone: none1.11.0
Owner: set to mikesherov
Priority: minormajor
Status: openassigned

Ugh. Ok, I'll fix this soon as well. I suppose when unraveling spaghetti, you're bound to get some sauce on your shirt.

comment:5 Changed 4 years ago by glebonator

Is this the cause of the issue seen here? http://jsfiddle.net/mefa/zrNNZ/15/

Draggable elements jump in FF with anything past 1.8.3 Draggable elements jump in Chrome with 1.8.3

Dragging doesn't work :-\

comment:6 in reply to:  5 ; Changed 4 years ago by tj.vantoll

Replying to glebonator:

Is this the cause of the issue seen here? http://jsfiddle.net/mefa/zrNNZ/15/

Draggable elements jump in FF with anything past 1.8.3 Draggable elements jump in Chrome with 1.8.3

Dragging doesn't work :-\

That's #9315, which has already been fixed in master.

comment:7 in reply to:  6 Changed 4 years ago by glebonator

Thanks, copying in both _convertPositionTo() and _generatePosition() from main has fixed my issue.

Replying to tj.vantoll:

Replying to glebonator:

Is this the cause of the issue seen here? http://jsfiddle.net/mefa/zrNNZ/15/

Draggable elements jump in FF with anything past 1.8.3 Draggable elements jump in Chrome with 1.8.3

Dragging doesn't work :-\

That's #9315, which has already been fixed in master.

comment:8 Changed 4 years ago by Scott González

#9617 is a duplicate of this ticket.

comment:9 Changed 3 years ago by mattdeclaire

comment:10 Changed 3 years ago by Mike Sherov

Resolution: fixed
Status: assignedclosed

Draggable: normalize lookups for rootNodes when to bust scroll cache. Fixes #9379 - Draggable: position bug in scrollable div Core: update scrollParent() to support all current supported browsers.

Changeset: 44b2180782df6ef3324789324fcf3f98b85784a0

comment:11 Changed 3 years ago by mikesherov

Milestone: 1.11.01.10.4

comment:12 Changed 3 years ago by Scott González

Milestone: 1.10.41.11.0

@mikesherov This isn't going to cherry-pick cleanly into 1-10-stable. You can try to resolve the conflicts, but there were some big changes in draggable that didn't get cherry-picked, so pretty much everything results in a conflict.

Note: See TracTickets for help on using tickets.