Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _watch() {
if (this.watching) {
return
}
// must watch scroll in real time
this.bscroll.options.probeType = Probe.Realtime
this.watching = true
this.bscroll.on('scroll', this._checkToEnd, this)
}
move(
startPoint: TranslaterPoint,
endPoint: TranslaterPoint,
time: number,
easingFn: string | EaseFn,
isSlient?: boolean
) {
this.setPending(
time > 0 && (startPoint.x !== endPoint.x || startPoint.y !== endPoint.y)
)
this.transitionTimingFunction(easingFn as string)
this.transitionTime(time)
this.translate(endPoint)
if (time && this.options.probeType === Probe.Realtime) {
this.startProbe()
}
// if we change content's transformY in a tick
// such as: 0 -> 50px -> 0
// transitionend will not be triggered
// so we forceupdate by reflow
if (!time) {
this._reflow = this.content.offsetHeight
}
// no need to dispatch move and end when slient
if (!time && !isSlient) {
this.hooks.trigger(this.hooks.eventTypes.move, endPoint)
this.hooks.trigger(this.hooks.eventTypes.end, endPoint)
private _watch() {
// 需要设置 probe = 3 吗?
// must watch scroll in real time
this.scroll.options.probeType = Probe.Realtime
this.scroll.scroller.hooks.on('end', this._checkPullDown, this)
}
constructor(public bscroll: BScroll) {
if (bscroll.options.infinity) {
this.bscroll.options.probeType = Probe.Realtime
this.bscroll.scroller.scrollBehaviorY.hasScroll = true
this.bscroll.scroller.scrollBehaviorY.maxScrollPos = EXTRA_SCROLL_Y
this.init(bscroll.options.infinity)
}
}
private transitionEnd(e: TouchEvent) {
if (e.target !== this.content || !this.animater.pending) {
return
}
const animater = this.animater as Transition
animater.transitionTime()
if (!this.resetPosition(this.options.bounceTime, ease.bounce)) {
this.animater.setPending(false)
if (this.options.probeType !== Probe.Realtime) {
this.hooks.trigger(
this.hooks.eventTypes.scrollEnd,
this.getCurrentPos()
)
}
}
}