简体   繁体   English

在Raphael.js上提高条形动画

[英]Raising up bar animation on Raphael.js

How to make animation go right? 如何使动画顺利进行? I mean I want to make bar raising up. 我的意思是我想提高标准。 But now the right bottom point doesn't stay static like the left one. 但是现在,右底点不再像左底那样保持静止。 It goes from left to right by animation. 通过动画从左到右。

https://jsfiddle.net/kholmukhamedovme/m4q4Lmbr/ https://jsfiddle.net/kholmukhamedovme/m4q4Lmbr/

var paper = Raphael("paper", 500, 500);

var bar = paper.path(
    "M 100, 500" +
    "L 200, 450" +
    "L 300, 500" +
    "Z"
).animate({
    path:
        "M 100, 350" +
        "L 200, 300" +
        "L 300, 350" +
        "L 300, 500" +
        "L 100, 500" +
        "Z"
}, 1000).attr("fill", "green").attr("stroke", "none");

The reason the line is coming from the bottom left is because there are 3 points in the first path and 5 in the second. 该线从左下角开始的原因是,第一条路径中有3个点,第二条路径中有5个点。 To create the animation the extra points are given a default starting point of the first point. 要创建动画,将为附加点指定第一个点的默认起点。 (100, 500). (100,500)。

Note: Also look at the attr function. 注意:还要查看attr函数。 You can pass a JSON object to it containing all of the attributes you want instead of calling attr multiple times. 您可以将包含所有所需属性的JSON对象传递给它,而无需多次调用attr

$(function(){

  var paper = Raphael("paper", 500, 500);

  var bar = paper.path(
    "M 100, 500" +
    "L 200, 450" +
    "L 300, 500" +
    "L 300, 500" +
    "L 100, 500" +
    "Z"
  ).animate({
    path:
        "M 100, 350" +
        "L 200, 300" +
        "L 300, 350" +
        "L 300, 500" +
        "L 100, 500" +
        "Z"
  }, 500).attr({
     fill: "green",
     stroke: "none"
  });

});

JSFiddle JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM