我是jquery的新手,正在学习snap.svg,不知道这段代码是如何工作的?有人可以解释一下函数是如何得到值的
I'm new to jquery and learning snap.svg and don't kow how this code work? Can someone Please explain how the function is getting values?
var s = Snap("#svgout");
var innerCircle = s.circle(150, 150, 80).attr({
fill: "none",
stroke: 'red',
strokeWidth: 30,
strokeDasharray: "10 300 40 10 10 10 10 10 10 10 10 10 10 10 10 10 10",
strokeDashoffset: 50
});
代码如下。这个函数是如何工作的?这些值是什么某种参数/参数/数组这些是什么?
Snap.animate(0,40, function( value ){ // 0,40 what are these?...
innerCircle.attr({ 'strokeDashoffset': value })
alert(value);
},5000 );
来自SnapSVG文档:
Snap.animate(from, to, setter, duration, [easing], [callback])
把你给Snap的电话分开。动画上图:
var from = 0; // starting value
var to = 40; // ending value
var setter = function ( value ) { // value will be somewhere between 0 and 40
innerCircle.attr({ 'strokeDashoffset': value })
}; // called by SnapSVG to change the strokeDashoffset
var duration = 5000; // 5000 milliseconds (or 5 seconds)
// Using the above values, this is the equivalent to your original call
Snap.animate( from, to, setter, duration );
0,40是动画的开始值和结束值
我认为'setter'函数是在整个持续时间内使用当前'value'调用的。该值将介于0和40之间,取决于它在动画中的距离(因此在2.5秒时,它将是20)
相关文章:
- 你能解释一下这个阶乘函数是如何工作的吗?
- 我如何才能让CasperJS和PhantomJS在约塞米蒂玩得很好
- 你能解释一下为什么这个javascript不正确吗
- 加载侦听器上的函数触发得太早
- 我怎么能让jQuery对话框表现得像Javascript警报
- “createImageData()”和“new ImageData(()”有何不同
- Javascript 如何强制 string.replace 不将我的字符串解释为正则表达式
- Appcelerator Titanium:在运行时下载并解释JavaScript代码
- $(window).load在带有异步js-libs的IE中触发得太快
- 注入的HTML仅在Dom中解释为字符串
- 对象.创建解释
- 我在下拉列表中尝试了下一个和前五年的html代码.接下来的5年我都过得很好.我怎样才能拿到之前的5年
- 无法解释的JavaScript行为-错误
- 使用ng选项,我如何筛选准确解释给定值的内容
- 在以下情况下解释 >= 和 <= 运算符的行为
- 如何使用粉笔终端字符串样式做得正确
- TypeScript解释了各种文件扩展名
- HTML按钮在单击时表现得很奇怪
- 有人能向我解释一下我犯的一个错误吗
- 请为javascript解释MVC中的VC