mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 00:38:49 +01:00
Delay onClose after swipe
This commit is contained in:
parent
7200acc2a7
commit
0feee7ea93
1 changed files with 3 additions and 1 deletions
|
@ -1272,8 +1272,9 @@ function Carousel({ mediaAttachments, index = 0, onClose = () => {} }) {
|
|||
const [showControls, setShowControls] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let swipeTimeout;
|
||||
let handleSwipe = () => {
|
||||
onClose();
|
||||
swipeTimeout = setTimeout(onClose, 500);
|
||||
};
|
||||
if (carouselRef.current) {
|
||||
carouselRef.current.addEventListener('swiped-down', handleSwipe);
|
||||
|
@ -1282,6 +1283,7 @@ function Carousel({ mediaAttachments, index = 0, onClose = () => {} }) {
|
|||
if (carouselRef.current) {
|
||||
carouselRef.current.removeEventListener('swiped-down', handleSwipe);
|
||||
}
|
||||
clearTimeout(swipeTimeout);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
Loading…
Reference in a new issue