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 @@
} }
} }
let disabled = false
function safeChangePage(cb) {
if (disabled) return
cb()
disabled = true
setTimeout(() => {
disabled = false
}, duration)
}
function showPage(pageIndex, { offsetDelay, animated }) { function showPage(pageIndex, { offsetDelay, animated }) {
safeChangePage(() => {
store.moveToPage({ pageIndex, pagesCount }) store.moveToPage({ pageIndex, pagesCount })
setTimeout(() => { setTimeout(() => {
offsetPage(animated) offsetPage(animated)
}, offsetDelay) }, offsetDelay)
})
} }
function showPrevPage() { function showPrevPage() {
safeChangePage(() => {
store.prev({ infinite, pagesCount }) store.prev({ infinite, pagesCount })
offsetPage(true) offsetPage(true)
})
} }
function showNextPage() { function showNextPage() {
safeChangePage(() => {
store.next({ infinite, pagesCount }) store.next({ infinite, pagesCount })
offsetPage(true) offsetPage(true)
})
} }
// gestures // gestures