Простой, используя Rapheal, я успешно делаю анимацию вдоль пути, но я не могу изменить направление анимации ,,, как сделать ее анимацией в другом направлении при нажатии на один и тот же путь.raphael изменить направление анимации
var paper = Raphael(0,0,1024,768);
var pathOne = paper.path(['M', 15,15 , 100,75]).attr({'stroke-width':18}).data("id",1);
//and this is just the circle
var circle = paper.circle(0, 0, 13).attr({
fill: '#09c', cursor: 'pointer'
});
//make the path as custom attribute so it can ba accessed
function pathPicker(thatPath){
paper.customAttributes.pathFactor = function(distance) {
var point = thatPath.getPointAtLength(distance * thatPath.getTotalLength());
var dx = point.x,
dy = point.y;
return {
transform: ['t', dx, dy]
};
}
}
//initialize for first move
pathPicker(pathOne);
circle.attr({pathFactor: 0}); // Reset
//Asign first path and first move
function firstMove(){
circle.animate({pathFactor: 1}, 1000});
}
pathOne.click(function(){
firstMove();
});
Можете ли вы заставить его работать над jsfiddle, так оно и есть, оно не работает. – Ian
Я обновил код, который должен теперь работать. спасибо –