javascript - SVG.js : Shapes extension: animate error

标签 javascript svg svg.js

下面是使用 SVG.js 形状扩展在 star 上创建的示例。当我请求将其从 7 点(尖峰)动画化到 10 点(尖峰)时,它会生成错误。

有什么想法吗?

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>SVG.js - Shapes Extension: animate error</title>
    <script type="text/javascript" src="//svgDiscovery.com/SVG.js/svg.js"></script>
    <script type="text/javascript" src="//svgDiscovery.com/SVG.js/Plugins/svg.shapes.js"></script>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width">
</head>
<body style='padding:10px;font-family:arial;'>
<center>
<h4>SVG.js - Shapes Extension: animate error</h4>
<table>
<tr>
<td>
<div id="svgDiv" style='background-color:lightgreen;width:400px;height:400px;'></div>
</td>
</tr></table>
<script id=myScript>
//---access the empty DIV---
var mySVG = SVG('svgDiv').size(400, 400);

var myStar = mySVG.polygon().attr({id:'myPolygon',stroke:'blue','stroke-width':3,fill:'yellow'}).star({
  inner:  50
, outer:  100
, spikes: 7
}).move(100,100)

//---creates error---
 myStar.animate().star({ spikes: 10 })
</script>
</body>
</html>

最佳答案

所以我抽出时间来更新这个扩展。它可以在 Bower 上使用,一旦包冲突在 npm 上得到解决,它也可以使用。

它现在需要 svg.js 版本 2,并且完全按照您指定的方式工作

mySVG
  .polygon()
  .ngon()
  .animate()
  .star()

关于javascript - SVG.js : Shapes extension: animate error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43723512/

相关文章:

javascript - 防止用户输入 0 作为输入

javascript - 子组件不会重新渲染,但父组件会重新渲染。如何让子组件重新渲染?

javascript - 适用于移动设备的 PhoneGap 和适用于桌面+移动设备的 Appcelerator?

javascript - 使 SVG 完全填满整个页面

javascript - 无法在 'appendChild' : Only one element on document allowed 上执行 'Node'

javascript - Highcharts + Plotband 工具提示悬停 + 默认样式

javascript - 确认 AngularJS 是否已安装并正常工作

javascript - 如何使用 svg.js 绘制圆弧

javascript - 嵌套 svg 忽略 Chrome 和 Opera 中的转换

javascript - 获取被拖动的 SVG 元素的 id