Disable page change while page changing is in progress

This commit is contained in:
Vadim
2021-01-31 21:24:13 +03:00
parent d298f2cba2
commit 70f67b6a8f

View File

@@ -144,19 +144,35 @@
} }
} }
function showPage(pageIndex, { offsetDelay, animated }) { let disabled = false
store.moveToPage({ pageIndex, pagesCount }) function safeChangePage(cb) {
if (disabled) return
cb()
disabled = true
setTimeout(() => { setTimeout(() => {
offsetPage(animated) disabled = false
}, offsetDelay) }, duration)
}
function showPage(pageIndex, { offsetDelay, animated }) {
safeChangePage(() => {
store.moveToPage({ pageIndex, pagesCount })
setTimeout(() => {
offsetPage(animated)
}, offsetDelay)
})
} }
function showPrevPage() { function showPrevPage() {
store.prev({ infinite, pagesCount }) safeChangePage(() => {
offsetPage(true) store.prev({ infinite, pagesCount })
offsetPage(true)
})
} }
function showNextPage() { function showNextPage() {
store.next({ infinite, pagesCount }) safeChangePage(() => {
offsetPage(true) store.next({ infinite, pagesCount })
offsetPage(true)
})
} }
// gestures // gestures