如何在点击时触发 css 3d 动画
我正在制作一个折叠隐藏/显示动画,我希望能够用 javascript 触发它。
这是代码和工作示例: http://dabblet.com/gist/1654665
如果您愿意的话,只是要点: https://gist.github.com/1654665
目前,打开和关闭动画是为了简单起见,在相同的关键帧集中。如果我可以解决点击时触发折叠+展开效果的问题,那么我可以将其分成两个单独的动画。
我尝试过使用 jQuery 的 animate 函数,但它似乎无法识别旋转和翻译 CSS3/webkit 魔法。我还尝试将动画名称属性移动到 .unfold 状态并使用 jQuery 设置 $("#stage").toggleClass("do_animation");
#stage.do_animation #topfold{
animation-name: topfold;
}
#stage.do_animation #bottomfold{
animation-name: bottomfold;
}
#stage.do_animation{
animation-name: collapse_expand;
}
...我还有一些其他想法我打算尝试一下,但我想我应该把这个问题提出来,因为我确信你们中的许多人对此类事情有更多的经验。
最后,如果有人有兴趣与我一起研究这个问题,使其达到可以轻松用于隐藏/显示各种内容的状态,我会喜欢这家公司。该动画的灵感来自于 OSX Mail 中用于展开引用文本的动画,我'我很乐意看到它达到那样的质量水平。
I'm working on a folding hide/show animation that I'd like to be able to trigger with javascript.
Here's the code and working example:
http://dabblet.com/gist/1654665
Of just the gist if you prefer:
https://gist.github.com/1654665
For the time-being, the open and close animations are within the same keyframe sets for simplicity's sake. If I can solve the problem of triggering the fold+unfold effect on click, then I can deal with splitting it up into 2 separate animations.
I've tried using jQuery's animate function but it doesn't seem to recognize the rotate and translate CSS3/webkit magic. I also tried moving the animation-name property to an .unfold state and using jQuery to set $("#stage").toggleClass("do_animation");
#stage.do_animation #topfold{
animation-name: topfold;
}
#stage.do_animation #bottomfold{
animation-name: bottomfold;
}
#stage.do_animation{
animation-name: collapse_expand;
}
...I have some other ideas that I plan on trying, but I thought I'd throw the question out there since I'm sure many of you have much more experience with this sort of thing.
Lastly, if anyone out there is interested in working on this with me to bring it to a state where it can be easily used to hide/show all kinds of content, I'd love the company. The animation is inspired by the one used to expand quoted text in OSX Mail and I'd love to see it through to that level of quality.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
按要求答复。
请参阅小提琴了解更多详细信息..
(我当前的版本正在使用 2d-transforms.. 我在发现这个问题之前做了这个)
不过这可能会有所帮助..
http://jsfiddle.net/pixelass/a74Eu/32/
我正在工作一个 jQuery 插件。
我当前的 jQuery(请看小提琴)
Answer on request.
Please see the fiddle for more detail..
(my current version is using 2d-transforms.. I made this before I found this question)
this might help though..
http://jsfiddle.net/pixelass/a74Eu/32/
I am working on a jQuery plugin for this.
my current jQuery (please look at the fiddle)
啊,我发现触发 css3 动画的好方法是在样式表中设置动画的基本状态(在其中添加 css3 动画属性),
并且您可以使用类似的东西轻松触发它们...
当我想要整个动画时,我通常使用这个div 触发动作,而不仅仅是我的带有锚点的文本或图像
ah good way I find to trigger css3 animations it's to set your base state of animation in your stylesheet (where you add css3 animation properties)
and you can easily trigger them with something like this...
I usally use this when i want the entire div triggers the action and not only my text or images with anchor
我所做的就是像这样更改 CSS:
然后在 JS 中我所做的是某种:
它对我有用。所以解决方案应该是:
What I did was to change the CSS like this:
Then in the JS what I did was some kind of:
And it worked for me. So the solution should be: