From c5cadbc0038de0b617d24a83a35481d83c0b7efe Mon Sep 17 00:00:00 2001 From: Alex B <42856876+IArny@users.noreply.github.com> Date: Sat, 5 Mar 2022 18:04:20 +0300 Subject: [PATCH] fix: Fix dragging on iOS when zooming 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. --- src/SortableContainer/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SortableContainer/index.js b/src/SortableContainer/index.js index 9b24a045..d5065dbf 100644 --- a/src/SortableContainer/index.js +++ b/src/SortableContainer/index.js @@ -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, ); } @@ -220,6 +223,7 @@ export default function sortableContainer( if (!sorting) { if (!distance) { clearTimeout(this.pressTimer); + this.pressTimer = 0; } this.manager.active = null; }