小程序购物车抛物线动画的实现,,,要怎样开发,,,下面为各人介绍这篇文章。。。。。

要实现抛物线动画,,,我其时想到的是用插件的方式,,,网上有许多,,,可是要兼容小程序照旧有点难题,,,况且小程序的主包有2M限制;
那么怎样在小程序中实现这种效果呢?
wx.createAnimation css3 transition
实现方式有了,,,我们再来看一下什么是抛物线,,,数学上界说抛物线的种类有许多,,,但就上图的效果而言,,,需要 水平偏向匀速运动 & 笔直偏向加速运动 ; wx.createAnimation 提供 timingFunction , 即水平偏向 linear , 笔直偏向 ease-in
本次实现基于 wepy框架 (非小程序原生),,,以是 $apply ---> setData 就好了~
html
<view class="box">
<view>
<button bindtap="handleClick">点击</button>
</view>
<view animation="{{animationY}}" style="position:fixed;top:{{ballY}}px;" hidden="{{!showBall}}">
<view class="ball" animation="{{animationX}}" style="position:fixed;left:{{ballX}}px;"></view>
</view>
</view>
JS
// 设置延迟时间
methods = {
handleClick: (e) => {
// x, y体现手指点击横纵坐标, 即小球的起始坐标
let ballX = e.detail.x,
ballY = e.detail.y;
this.isLoading = true;
this.$apply();
this.createAnimation(ballX, ballY);
}
}
setDelayTime(sec) {
return new Promise((resolve, reject) => {
setTimeout(() => {resolve()}, sec)
});
}
// 建设动画
createAnimation(ballX, ballY) {
let that = this,
bottomX = that.$parent.globalData.windowWidth,
bottomY = that.$parent.globalData.windowHeight-50,
animationX = that.flyX(bottomX, ballX), // 建设小球水平动画
animationY = that.flyY(bottomY, ballY); // 建设小球笔直动画
that.ballX = ballX;
that.ballY = ballY;
that.showBall = true;
that.$apply();
that.setDelayTime(100).then(() => {
// 100ms延时, 确保小球已经显示
that.animationX = animationX.export();
that.animationY = animationY.export();
that.$apply();
// 400ms延时, 即小球的抛物线时长
return that.setDelayTime(400);
}).then(() => {
that.animationX = this.flyX(0, 0, 0).export();
that.animationY = this.flyY(0, 0, 0).export();
that.showBall = false;
that.isLoading = false;
that.$apply();
})
}
// 水平动画
flyX(bottomX, ballX, duration) {
let animation = wx.createAnimation({
duration: duration || 400,
timingFunction: 'linear',
})
animation.translateX(bottomX-ballX).step();
return animation;
}
// 笔直动画
flyY(bottomY, ballY, duration) {
let animation = wx.createAnimation({
duration: duration || 400,
timingFunction: 'ease-in',
})
animation.translateY(bottomY-ballY).step();
return animation;
}
KESION pp电子软件
KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。。。。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。。。。。KESION 一直通过手艺立异,,,提供产品和服务,,,助力企业向数字化转型,,,通过科技驱动商业刷新,,,让商业变得更智慧!
微信 小程序 api阻挡器 完善兼容原生小程序项目 完善兼用小程序api的原本挪用方式,,,无痛迁徙 小程序api全Promise化 和axios一样的请求方式 小程序api自界说阻挡挪用参数和返回效果
小程序给每个行业带来许多盈利,,,使线下与线上人群加以联络,,,并带来精准的流量人群,,,提高了线上流量转化率,,,那么关于教育培训行业来说要怎样去开发小程序呢。。。。。...