如何使用 Raphael.js 旋转 div?
我是 Raphael 的新手,我真的很困惑,我想使用 Raphael 的按钮来旋转 div 及其内容。
理想情况下,我希望有一个平滑的动画,当单击按钮时,动画从 0 度变为 -90 度,然后当再次单击按钮时,动画将反转。我想我会更改鼠标单击时的 id 或类,以便我可以对两个动画使用相同的按钮。这明智吗?
我真的需要一些帮助,我的沙盒位于 http://jsbin.com/isijo/ ,你可以在 http://jsbin.com/isijo/edit 进行编辑
非常感谢您的帮助。
I am brand new to Raphael and am really stuck, I would like to rotate a div and its contents, using a button, with Raphael.
Ideally, I would like to have a smooth animation that goes from 0 degrees to -90 degrees when the button is clicked, then when the button is clicked again, the animation would reverse. I think I will change the id or class on mouse click so that I can use the same button for both animations. Would that be wise?
I really would like some help please, my Sandbox is at http://jsbin.com/isijo/ and you can edit it at http://jsbin.com/isijo/edit
Many thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您好,欢迎来到拉斐尔!
我已经研究 Raphael 几个多月了,虽然文档不是很全面,但软件非常棒。
我一直在以多种方式将 Div 与 Raphael 对象混合在一起,并且对哪些有效、哪些无效有了“感觉”。
我建议您不要尝试旋转 div,而是尝试旋转 Raphael 对象。
首先,您可以使用下面的“可调整”代码制作一组闪亮的拉斐尔按钮。
接下来您需要了解有关旋转集的更多信息:
这显示了最后一个“集”的旋转程度和旋转中心线。
我的附加 Raphael 资源网站旨在补充文档(除其他外):
http://www. irunmywebsite.com/raphael/raphaelsource.html
您可以在此处运行上述 2 个代码示例,无需更改:
http://raphaeljs.com/playground.html
我希望这有帮助......
Hello and welcome to Raphael!
I have been looking at Raphael for more than a few months and although the documentation is not very comprehensive the software is brilliant.
I have been mixing Divs with Raphael objects in many ways and have got a "feel" for what works and what does not work.
I am recommending that you do not try rotating divs but (instead) Raphael objects.
First of all you could make a shiney set of Raphael buttons using this "tweakable" code below..
Next you need to know more about rotating Sets:
This shows the degree of rotation and the centre of rotation of the "set" on the last line.
My additional Raphael resources website which aims to supplement documentation (Amongst other things):
http://www.irunmywebsite.com/raphael/raphaelsource.html
Heres where you can run the above 2 code examples without alteration:
http://raphaeljs.com/playground.html
I'm hoping this helped...
据我所知,没有办法将 div 转换为 Raphael 对象。由于 Raphael 旋转命令仅为 Raphael 对象定义,因此最好的选择是在 Raphael 而不是 HTML 中创建 div 的主要元素(图像、文本、按钮等),将它们放在一个集合中,并且,如该集合是拉斐尔对象,旋转该集合。
To my knowledge, there is no way to convert a div into a Raphael object. Since the Raphael rotate command is only defined for Raphael objects, your best bet is to create the major elements of your div (images, text, buttons and all) in Raphael instead of HTML, put them together in a single set, and, as the set is a Raphael object, rotate the set.
请参阅在 CSS 和 IE 过滤器中旋转 div。这与
SVG
不同,因此如果您需要更多布局魔法,Raphael 形状可能是最佳选择。您应该能够将 JQuery 与 Raphael 配合使用来在窗口中操作两者,但我对 Raphael 来说是全新的,从未这样做过。Consult Rotate a div in CSS and in IE filters. This is not the same as
SVG
, so if you need more layout magic, Raphael shapes are likely the way to go. You should be able to usedJQuery
in concert with Raphael to manipulate both in your window, but I am brand new to Raphael and have never done so.