在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

better-scroll 插件源码中 momentum 函数 ,动量公式推导的?如何学习呢

// this.x, this.startX, duration, this.maxScrollX|Y, this.options.bounce ? this.wrapperWidth|Height : 0, this.options    export function momentum(current, start, time, lowerMargin, wrapperSize, options) {            let distance = current - start;            let speed = Math.abs(distance) / time;    //  deceleration = 0.001, itemHeight, swipeBounceTime = 1200, bounceTime = 700            let {deceleration, itemHeight, swipeBounceTime, bounceTime} = options;    // swipeTime = 2500            let duration = options.swipeTime;            let rate = options.wheel ? 4 : 15;    //     // (distance < 0 ? -1 : 1) 判断往上滚动,还是往下滚动            let destination = current + speed / deceleration * (distance < 0 ? -1 : 1);            if (options.wheel && itemHeight) {                    destination = Math.round(destination / itemHeight) * itemHeight;            }    // destination < lowerMargin判断往(下|右)方向, destination > 0 相反            if (destination < lowerMargin) {    //                     destination = wrapperSize ? lowerMargin - (wrapperSize / rate * speed) : lowerMargin;                    duration = swipeBounceTime - bounceTime;            } else if (destination > 0) {    //                    destination = wrapperSize ? wrapperSize / rate * speed : 0;                    duration = swipeBounceTime - bounceTime;            }            return {                    destination: Math.round(destination),                    duration            };    };

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

发新帖
国内首家创新型IT技术需求众包服务平台,软件需求就上天盟网! 立即登录 立即注册