Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private momentum(pos: TranslaterPoint, duration: number) {
const meta = {
time: 0,
easing: ease.swiper,
newX: pos.x,
newY: pos.y
}
// start momentum animation if needed
const momentumX = this.scrollBehaviorX.end(duration)
const momentumY = this.scrollBehaviorY.end(duration)
meta.newX = isUndef(momentumX.destination)
? meta.newX
: (momentumX.destination as number)
meta.newY = isUndef(momentumY.destination)
? meta.newY
: (momentumY.destination as number)
meta.time = Math.max(
momentumX.duration as number,
momentumY.duration as number
)
this.hooks.trigger(this.hooks.eventTypes.momentum, meta, this)
// when x or y changed, do momentum animation now!
if (meta.newX !== pos.x || meta.newY !== pos.y) {
// change easing function when scroller goes out of the boundaries
if (
meta.newX > this.scrollBehaviorX.minScrollPos ||
meta.newX < this.scrollBehaviorX.maxScrollPos ||
meta.newY > this.scrollBehaviorY.minScrollPos ||
meta.newY < this.scrollBehaviorY.maxScrollPos
private momentum(pos: TranslaterPoint, duration: number) {
const meta = {
time: 0,
easing: ease.swiper,
newX: pos.x,
newY: pos.y
}
// start momentum animation if needed
const momentumX = this.scrollBehaviorX.end(duration)
const momentumY = this.scrollBehaviorY.end(duration)
meta.newX = isUndef(momentumX.destination)
? meta.newX
: (momentumX.destination as number)
meta.newY = isUndef(momentumY.destination)
? meta.newY
: (momentumY.destination as number)
meta.time = Math.max(
momentumX.duration as number,
momentumY.duration as number
)
this.hooks.trigger(this.hooks.eventTypes.momentum, meta, this)
// when x or y changed, do momentum animation now!
if (meta.newX !== pos.x || meta.newY !== pos.y) {
// change easing function when scroller goes out of the boundaries
if (
meta.newX > this.scrollBehaviorX.minScrollPos ||
static use(ctor: PluginCtor) {
const name = ctor.pluginName
const installed = this.plugins.some(plugin => ctor === plugin.ctor)
if (installed) return this
if (isUndef(name)) {
warn(
`Plugin Class must specify plugin's name in static property by 'pluginName' field.`
)
return this
}
if (this.pluginsMap[name]) {
warn(
`This plugin has been registered, maybe you need change plugin's name`
)
return this
}
this.pluginsMap[name] = true
this.plugins.push({
name,
enforce: ctor.enforce,
ctor