[英]How to animate an image along a path with Bezier curves
我的目標:
我考慮過的
我的計划
我的問題
有一個小腳本(基於SVG),只適用於不是直線的動畫,
叫做pathAnimator (2kb),它非常小而且效率很高。
不需要jQuery。
var path = "M150 0 L75 200 L225 200 Z"; // an SVG path
pathAnimator = new PathAnimator( path ), // initiate a new pathAnimator object
speed = 6, // seconds that will take going through the whole path
reverse = false, // go back or forward along the path
startOffset = 0, // between 0% to 100%
easing = function(t){ t*(2-t) }; // optional easing function
pathAnimator.start( speed, step, reverse, startOffset, finish, easing);
function step( point, angle ){
// do something every "frame" with: point.x, point.y & angle
}
function finish(){
// do something when animation is done
}
(使用fastdom甚至可以提高效率)
我建議你使用GSAP: http : //www.greensock.com/get-started-js/
有了它你可以處理時間表,這是一個bezier插件: http : //api.greensock.com/js/com/greensock/plugins/BezierPlugin.html
問候
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.