Skip to content

Commit

Permalink
fix: Fix dragging on iOS when zooming
Browse files Browse the repository at this point in the history
This commit is fixing a bug when user of iOS zooming screen with sortable elements. When two sortable items are touched then ```handlePress``` function fires two times and after releasing item one of them runs away from screen.
  • Loading branch information
IArny committed Mar 5, 2022
1 parent 8c41865 commit c5cadbc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/SortableContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,12 @@ export default function sortableContainer(
if (!distance) {
if (this.props.pressDelay === 0) {
this.handlePress(event);
} else {
} else if (!this.pressTimer) {
this.pressTimer = setTimeout(
() => this.handlePress(event),
() => {
this.pressTimer = 0;
this.handlePress(event);
},
this.props.pressDelay,
);
}
Expand Down Expand Up @@ -220,6 +223,7 @@ export default function sortableContainer(
if (!sorting) {
if (!distance) {
clearTimeout(this.pressTimer);
this.pressTimer = 0;
}
this.manager.active = null;
}
Expand Down

0 comments on commit c5cadbc

Please sign in to comment.