最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

基于HTML5Canvas和Rebound动画的Loading加载动画特效

来源:动视网 责编:小采 时间:2020-11-27 15:13:15
文档

基于HTML5Canvas和Rebound动画的Loading加载动画特效

基于HTML5Canvas和Rebound动画的Loading加载动画特效:简要教程这是一款基于HTML5 canvas和Rebound动画的Loading加载动画特效。该loading动画使用canvas来覆盖整个页面,并显示多边形的loading加载器来表示加载进度。1、创建一个SpringSystem。// Create a SpringSystem. let spri
推荐度:
导读基于HTML5Canvas和Rebound动画的Loading加载动画特效:简要教程这是一款基于HTML5 canvas和Rebound动画的Loading加载动画特效。该loading动画使用canvas来覆盖整个页面,并显示多边形的loading加载器来表示加载进度。1、创建一个SpringSystem。// Create a SpringSystem. let spri


简要教程

这是一款基于HTML5 canvas和Rebound动画的Loading加载动画特效。该loading动画使用canvas来覆盖整个页面,并显示多边形的loading加载器来表示加载进度。

1、创建一个SpringSystem。

// Create a SpringSystem.
 let springSystem = new rebound.SpringSystem();

2、在系统中添加一个弹簧。

// Add a spring to the system.
 demo.spring = springSystem.createSpring(settings.tension, settings.friction);

3、为弹簧添加SpringListener事件监听。

_addSpringListener() {
 
 let ctx = this;
 
 // Add a listener to the spring. Every time the physics
 // solver updates the Spring's value onSpringUpdate will
 // be called.
 this._spring.addListener({
 // ...
 });
}

4、设置弹簧的结束动画值,参数为开始动画的当前值。

this._spring.setEndValue((this._spring.getCurrentValue() === 1) ? 0 : 1);

5、在onSpringUpdate回调函数中设置动画的进度。

onSpringUpdate(spring) {
 
 let val = spring.getCurrentValue();
 
 // Input range in the `from` parameters.
 let fromLow = 0,
 fromHigh = 1,
 // Property animation range in the `to` parameters.
 toLow = ctx._springRangeLow,
 toHigh = ctx._springRangeHigh;
 
 val = rebound.MathUtil.mapValueInRange(val, fromLow, fromHigh, toLow, toHigh);
 
 // Note that the render method is
 // called with the spring motion value.
 ctx.render(val);
}

文档

基于HTML5Canvas和Rebound动画的Loading加载动画特效

基于HTML5Canvas和Rebound动画的Loading加载动画特效:简要教程这是一款基于HTML5 canvas和Rebound动画的Loading加载动画特效。该loading动画使用canvas来覆盖整个页面,并显示多边形的loading加载器来表示加载进度。1、创建一个SpringSystem。// Create a SpringSystem. let spri
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top