如何使用 Scripty 2 改变类?
在 Scriptaculous 1 中,您可以对样式进行动画处理:
new Effect.Morph('id', {
style: { background: tomato },
duration: '4' });
但更好的方法是将 CSS 和 JS 分开,仅引用一个类:
new Effect.Morph('id', {
style: 'important',
duration: '4' });
Marvelous。但这似乎不适用于新的 Scripty 2。 工作:
$('id').morph('background: tomato', { duration: 4 });
中断:
$('id').morph('important', { duration: 4 });
在 Scripty 2 中使用类制作动画的正确方法是什么? (我怀疑 样式,但文档含糊不清。)
In Scriptaculous 1, you could animate styles:
new Effect.Morph('id', {
style: { background: tomato },
duration: '4' });
But a better way was to keep the CSS and JS separate and merely reference a class:
new Effect.Morph('id', {
style: 'important',
duration: '4' });
Marvellous. But this doesn't seem to work with the new Scripty 2. Works:
$('id').morph('background: tomato', { duration: 4 });
Breaks:
$('id').morph('important', { duration: 4 });
What is the right way to animate using a class in Scripty 2? (I suspected Style, but the docs were vague.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我查看了源代码,s2 仅采用“styleProp:value”作为样式选项。该字符串需要有一个冒号。
唯一另外采用类名以及样式选项“styleProp:value”的方法是名为 S2.FX.Operators.WebkitCssTransition 的方法。但是,S2.Extensions.webkitCSSTransitions 默认情况下处于关闭状态。尽管如此,该方法中的代码可用于为 .Morph 方法制作您自己的补丁。
I checked out the source code and s2 only takes 'styleProp:value' for the style option. The string needs to have a colon.
The only method that will additionally take the class name as well 'styleProp:value' for the style option is a method called S2.FX.Operators.WebkitCssTransition. However, the S2.Extensions.webkitCSSTransitions are turned off by default. Although, the code in that method to be used to make your own patch to the .Morph method.