问题描述
我正在使用 SVG 和 JavaScript/jQuery 开发交互式界面,我正在尝试在 Raphael 和 jQuery SVG.我想知道
I'm working on an interactive interface using SVG and JavaScript/jQuery, and I'm trying to decide between Raphael and jQuery SVG. I'd like to know
- 两者之间的权衡是什么
- 发展势头似乎在哪里.
我不需要 Raphael 中的 VML/IE 支持,或者 jQuery SVG 的绘图能力.我主要对在 SVG 画布上创建、动画和操作单个项目的最优雅方式感兴趣.
I don't need the VML/IE support in Raphael, or the plotting abilities of jQuery SVG. I'm primarily interested in the most elegant way to create, animate, and manipulate individual items on an SVG canvas.
推荐答案
我最近同时使用了 Raphael 和 jQuery SVG - 以下是我的想法:
I've recently used both Raphael and jQuery SVG - and here are my thoughts:
优点:一个很好的入门库,可以轻松快速地使用 SVG 做很多事情.写得很好,有据可查.大量示例和演示.非常可扩展的架构.动画很棒.
Pros: a good starter library, easy to do a LOT of things with SVG quickly. Well written and documented. Lots of examples and Demos. Very extensible architecture. Great with animation.
缺点: 是实际 SVG 标记之上的一层,使得难以用 SVG 做更复杂的事情 - 例如分组(它支持集合,但不支持组).编辑现有元素时效果不佳.
Cons: is a layer over the actual SVG markup, makes it difficult to do more complex things with SVG - such as grouping (it supports Sets, but not groups). Doesn't do great w/ editing of already existing elements.
优点:一个 jquery 插件,如果你已经在使用 jQuery.写得很好,有据可查.很多例子和演示.支持大多数 SVG 元素,允许轻松访问元素
Pros: a jquery plugin, if you're already using jQuery. Well written and documented. Lots of examples and demos. Supports most SVG elements, allows native access to elements easily
缺点:架构不像 Raphael 那样可扩展.有些事情可以更好地记录(例如 SVG 元素的配置).编辑现有元素时效果不佳.动画依赖于 SVG 语义 - 这不是很好.
Cons: architecture not as extensible as Raphael. Some things could be better documented (like configure of SVG element). Doesn't do great w/ editing of already existing elements. Relies on SVG semantics for animation - which is not that great.
SnapSVG 是 Raphael 的继承者.它仅在支持 SVG 的浏览器中受支持,并且几乎支持 SVG 的所有功能.
SnapSVG is the successor of Raphael. It is supported only in the SVG enabled browsers and supports almost all the features of SVG.
如果您想快速轻松地做某事,Raphael 是一个简单的选择.如果您打算做一些更复杂的事情,我选择使用 jQuery SVG,因为与使用 Raphael 相比,我可以更轻松地操作实际标记.如果您想要一个非 jQuery 解决方案,那么 SnapSVG 是一个不错的选择.
If you're doing something quick and easy, Raphael is an easy choice. If you're going to do something more complex, I chose to use jQuery SVG because I can manipulate the actual markup significantly easier than with Raphael. And if you want a non-jQuery solution then SnapSVG is a good option.
这篇关于jQuery SVG 与 Raphael的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!