Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
y: prev.y + current.y
}
},
{ x: 0, y: 0 }
)
this.deltaCache = []
let newX = this.scroll.x + Math.round(delta.x) + cachedDelta.x
let newY = this.scroll.y + Math.round(delta.y) + cachedDelta.y
const scrollBehaviorX = this.scroll.scroller.scrollBehaviorX
const scrollBehaviorY = this.scroll.scroller.scrollBehaviorY
newX = fixInboundValue(
newX,
scrollBehaviorX.maxScrollPos,
scrollBehaviorX.minScrollPos
)
newY = fixInboundValue(
newY,
scrollBehaviorY.maxScrollPos,
scrollBehaviorY.minScrollPos
)
if (
!this.scroll.trigger(this.scroll.eventTypes.mousewheelMove, {
x: newX,
y: newY
})
) {
const easeTime = this.getEaseTime()
if (newX !== this.scroll.x || newY !== this.scroll.y) {
this.scroll.scrollTo(newX, newY, easeTime)
}
}
} else {
const cachedDelta = this.deltaCache.reduce(
(prev, current) => {
return {
x: prev.x + current.x,
y: prev.y + current.y
}
},
{ x: 0, y: 0 }
)
this.deltaCache = []
let newX = this.scroll.x + Math.round(delta.x) + cachedDelta.x
let newY = this.scroll.y + Math.round(delta.y) + cachedDelta.y
const scrollBehaviorX = this.scroll.scroller.scrollBehaviorX
const scrollBehaviorY = this.scroll.scroller.scrollBehaviorY
newX = fixInboundValue(
newX,
scrollBehaviorX.maxScrollPos,
scrollBehaviorX.minScrollPos
)
newY = fixInboundValue(
newY,
scrollBehaviorY.maxScrollPos,
scrollBehaviorY.minScrollPos
)
if (
!this.scroll.trigger(this.scroll.eventTypes.mousewheelMove, {
x: newX,
y: newY
})
) {
}
let lastX = this.pagesPos.xLen - 1
let lastY = this.pagesPos.yLen - 1
let firstX = 0
let firstY = 0
if (this.loopX) {
x += 1
firstX = firstX + 1
lastX = lastX - 1
}
if (this.loopY) {
y += 1
firstY = firstY + 1
lastY = lastY - 1
}
x = fixInboundValue(x, firstX, lastX)
y = fixInboundValue(y, firstY, lastY)
return {
realX: x,
realY: y
}
}
nextPage(): { pageX: number; pageY: number } {
let lastX = this.pagesPos.xLen - 1
let lastY = this.pagesPos.yLen - 1
let firstX = 0
let firstY = 0
if (this.loopX) {
x += 1
firstX = firstX + 1
lastX = lastX - 1
}
if (this.loopY) {
y += 1
firstY = firstY + 1
lastY = lastY - 1
}
x = fixInboundValue(x, firstX, lastX)
y = fixInboundValue(y, firstY, lastY)
return {
realX: x,
realY: y
}
}
nextPage(): { pageX: number; pageY: number } {
y: 0,
pageX: 0,
pageY: 0
}
}
let pageX = pageInfo.pageX
let pageY = pageInfo.pageY
let newX
let newY
if (pageX === this.currentPage.pageX) {
pageX += directionX
pageX = fixInboundValue(pageX, 0, this.pagesPos.xLen - 1)
}
if (pageY === this.currentPage.pageY) {
pageY += directionY
pageY = fixInboundValue(pageInfo.pageY, 0, this.pagesPos.yLen - 1)
}
newX = this.pagesPos.getPos(pageX, 0).x
newY = this.pagesPos.getPos(0, pageY).y
return {
x: newX,
y: newY,
pageX,
pageY
}
}
getLoopStage(): LoopStage {
const pageInfo = this.pagesPos.getNearestPage(x, y)
if (!pageInfo) {
return {
x: 0,
y: 0,
pageX: 0,
pageY: 0
}
}
let pageX = pageInfo.pageX
let pageY = pageInfo.pageY
let newX
let newY
if (pageX === this.currentPage.pageX) {
pageX += directionX
pageX = fixInboundValue(pageX, 0, this.pagesPos.xLen - 1)
}
if (pageY === this.currentPage.pageY) {
pageY += directionY
pageY = fixInboundValue(pageInfo.pageY, 0, this.pagesPos.yLen - 1)
}
newX = this.pagesPos.getPos(pageX, 0).x
newY = this.pagesPos.getPos(0, pageY).y
return {
x: newX,
y: newY,
pageX,
pageY
}
}
getLoopStage(): LoopStage {