【问题标题】:I'm trying to translate or create similar code using RaphaelJS.我正在尝试使用 RaphaelJS 翻译或创建类似的代码。
【发布时间】:2014-11-18 02:19:48
【问题描述】:

我正在尝试使用 RaphaelJS 翻译或创建类似的代码。如果您查看代码,您会发现我正在尝试使用 css 和 js 创建动画路径。

http://plnkr.co/edit/FC2qiZumzgjKSJOs6Zm5?p=info

var spinner = function() {
this.transition = function() {
var path = document.querySelector('#spinner-wrapper .spinner #main-path');
path.style.transition = path.style.WebkitTransition = 'none';
path.style.strokeDasharray = '205.951';
path.style.strokeDashoffset = 430;
path.getBoundingClientRect();
path.style.strokeDashoffset = '0';
path.style.transition = path.style.WebkitTransition = 'stroke-dashoffset 3s linear';
};

this.startInterval = function(immediate,time) {
if(immediate){
  setTimeout(transition,0);
}
this.interval = setInterval(function() {
  transition();
}, time);
return this.interval;
};

this.start = function() {
clearInterval(this.interval);
startInterval(true,2700);
};

this.stop = function() {
clearInterval(this.interval);
startInterval(false,0);
};

return this;
};

【问题讨论】:

    标签: css svg raphael


    【解决方案1】:

    我正在使用 jQuery 和 RaphaelJS。由于某些原因,它仍然无法在 IE 浏览器中运行。也许你可以弄清楚。

    http://jsfiddle.net/shojib/ceqs86go/

    var paper = new Raphael('canvas');
    var pathString = "M16.47,19.938c7-0.5,4.5-10.5-2-7c-7,3.5,1,13,7.5,10 c13.5-7-9.5-27-16-6.5c-4.5,16,22,17,26,2c4.5-15.5-15-22.5-25-11.5c-5.5,6.5-9,16-0.5,21.5c4,2.5,15,6,19,2.5 c-3-3.5-7.5-8-9.5-10.5";
    
    
    var pattern2 = paper.path(pathString); 
    pattern2.attr({fill: 'none',stroke: '#ffffff',"stroke-miterlimit": '10','stroke-opacity': '1'}); 
    
    var pattern1 = paper.path(pathString); 
    pattern1.attr({fill: 'none',stroke: '#CD5300',"stroke-miterlimit": '10','stroke-opacity': '1'}); 
    
    $(pattern1.node).css({
    'stroke-dasharray': '210.991px',
    'stroke-dashoffset': '430px'
    });
    
    $(pattern1.node).animate({
    'stroke-dashoffset': '0'
    },{
    duration: 3000,
    easing: 'linear'
    });
    

    【讨论】:

    • 在 Chrome 中也不起作用。在这种情况下你真的需要使用 jquery(除非真的需要,否则访问 .node 总是感觉很笨拙)?这可能取决于您需要哪个 IE 版本,以及它是否支持此特定动画。
    猜你喜欢
    • 1970-01-01
    • 2014-07-26
    • 1970-01-01
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    • 2019-08-15
    • 2021-11-11
    • 2014-12-08
    相关资源
    最近更新 更多