Lock swipe on transition.

This commit is contained in:
Sergiotarxz 2023-11-29 16:58:17 +01:00
parent b18a6b5c57
commit 71b5ff1aa9
2 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,7 @@ export default class CarouselAd {
private ad: Ad | null = null private ad: Ad | null = null
private timeoutNumber: number | null = null private timeoutNumber: number | null = null
private firstAd = true private firstAd = true
private isLockedSwipe: boolean = false
private getCarousel(): HTMLElement { private getCarousel(): HTMLElement {
const carousel = document.querySelector('.carousel'); const carousel = document.querySelector('.carousel');
if (carousel === null || !(carousel instanceof HTMLElement)) { if (carousel === null || !(carousel instanceof HTMLElement)) {
@ -34,6 +35,9 @@ export default class CarouselAd {
end = event.pageX end = event.pageX
console.log(end) console.log(end)
if (start - end > 100) { if (start - end > 100) {
if (this.isLockedSwipe) {
return
}
if (this.timeoutNumber !== null) { if (this.timeoutNumber !== null) {
window.clearTimeout(this.timeoutNumber) window.clearTimeout(this.timeoutNumber)
} }
@ -136,6 +140,7 @@ export default class CarouselAd {
this.firstAd = false this.firstAd = false
} }
carousel.append(a) carousel.append(a)
this.isLockedSwipe = true
window.setTimeout(() => { window.setTimeout(() => {
a.classList.add('show') a.classList.add('show')
if (aPrev !== null) { if (aPrev !== null) {
@ -146,6 +151,7 @@ export default class CarouselAd {
for (const a of allAnchors) { for (const a of allAnchors) {
a.remove() a.remove()
} }
this.isLockedSwipe = false
}, 1000) }, 1000)
} }
}, 10) }, 10)

File diff suppressed because one or more lines are too long