renovations
This commit is contained in:
parent
05d35d0d16
commit
951cf3f2ec
152 changed files with 2527 additions and 2179 deletions
20
5-animation/3-js-animation/width.view/animate.js
Normal file
20
5-animation/3-js-animation/width.view/animate.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
function animate(options) {
|
||||
|
||||
var start = performance.now();
|
||||
|
||||
requestAnimationFrame(function animate(time) {
|
||||
// timeFraction от 0 до 1
|
||||
var timeFraction = (time - start) / options.duration;
|
||||
if (timeFraction > 1) timeFraction = 1;
|
||||
|
||||
// текущее состояние анимации
|
||||
var progress = options.timing(timeFraction)
|
||||
|
||||
options.draw(progress);
|
||||
|
||||
if (timeFraction < 1) {
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue