Skip to content

Commit bc623fc

Browse files
committed
Switched clientX/Y to pageX/Y so that it takes into account window scrolling.
1 parent ae50bb9 commit bc623fc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/SortableContainer/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ export default function sortableContainer(WrappedComponent, config = {withRef: f
144144

145145
this._touched = true;
146146
this._pos = {
147-
x: e.clientX,
148-
y: e.clientY,
147+
x: e.pageX,
148+
y: e.pageY,
149149
};
150150

151151
const node = closest(e.target, el => el.sortableInfo != null);
@@ -197,8 +197,8 @@ export default function sortableContainer(WrappedComponent, config = {withRef: f
197197

198198
if (!this.state.sorting && this._touched) {
199199
this._delta = {
200-
x: this._pos.x - e.clientX,
201-
y: this._pos.y - e.clientY,
200+
x: this._pos.x - e.pageX,
201+
y: this._pos.y - e.pageY,
202202
};
203203
const delta = Math.abs(this._delta.x) + Math.abs(this._delta.y);
204204

@@ -440,9 +440,10 @@ export default function sortableContainer(WrappedComponent, config = {withRef: f
440440
}
441441

442442
getOffset(e) {
443+
debugger
443444
return {
444-
x: e.touches ? e.touches[0].clientX : e.clientX,
445-
y: e.touches ? e.touches[0].clientY : e.clientY,
445+
x: e.touches ? e.touches[0].pageX : e.pageX,
446+
y: e.touches ? e.touches[0].pageY : e.pageY,
446447
};
447448
}
448449

0 commit comments

Comments
 (0)