jQuery 动画还是 jQuery 缓动?
跟我一起来解决这个问题。我正在尝试模仿 CSS3 过渡,并且(作为示例)我非常喜欢徽标的出现方式,并对 http 产生“反弹”效果://metalabdesign.com
我创建了一个快速的 jsFiddle 来说明我认为它如何与 jQuery 动画配合使用 http://jsfiddle.net/EEtVs/ 但老实说我不确定我是否应该使用 jQuery Easing http://gsgd.co.uk/sandbox/jquery/easing/ 将是这里更好的路线。
我或多或少正在寻找使用 jQuery 处理 easeIn 类型转换的最佳方法。我在小提琴中的路线是,我必须为那些没有启用它的人指定一个非 JS 版本(我知道,每个人都应该,只是说)并且我希望它可以在所有浏览器中工作(不仅仅是好的)这就是我选择 jQuery 路线的原因。
但是,我在 jQuery 方式中看到的问题是如何计算负顶部定位以及这如何影响实际的“过渡效果”。如果有人知道我如何使用 jQuery 缓动(或更好的方法)创建类似的东西,我将非常感激。我在尝试实现 jQuery 缓动方面遇到了很大的困难......所以现在真的陷入了困境。谢谢!
Stick with me on this one. I'm trying to mimick CSS3 transitions and (as an example) I quite liked how the logo came in and did a "bounce" effect on http://metalabdesign.com
I've created a quick jsFiddle on how I thought this might work with jQuery animations http://jsfiddle.net/EEtVs/ but am honestly not sure if I should be using jQuery Easing http://gsgd.co.uk/sandbox/jquery/easing/ would be the better route here.
I'm more or less looking for the best way to handle easeIn type transitions with jQuery. The route I went in my fiddle is, I'd have to specify a non-JS version for those who don't have it enabled (I know, EVERYONE should, just sayin) and I'd like it work in all browsers (not just the good ones) which is why I'm going the jQuery route.
But, the issue I'm seeing with my jQuery way is how I have the negative top positioning calculated and how that could effect the actual "transition effect". If anyone has an idea how I'd create something similar with jQuery easing (or a better way) I'd be very appreciative. I've had quite a struggle trying to implement jQuery easing... so really stuck in the mud at the moment. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将缓动插件添加到您的 jsfiddle 中,然后将新的缓动类型添加到您的
.animate()
调用中: http://jsfiddle.net/jasper/EEtVs/1/我还更改了要设置动画的元素的
top
值,因为它只需要大的足以在页面加载时隐藏元素。您可以通过将“easeOutBounce”更改为此页面上的任何缓动类型来更改缓动类型:http ://gsgd.co.uk/sandbox/jquery/easing/
如果您想确保您的元素显示在关闭 JavaScript 的浏览器中,请在页面头部运行一个添加类的脚本到 HTML像这样的元素:
现在,您可以为要跳入视图的元素制作两个版本的 CSS:
这会将元素的顶部设置为页面的顶部,除非启用了 JavaScript,在这种情况下,该元素将被隐藏,直到JavaScript 运行并显示该元素。
I added the easing plugin to your jsfiddle and then added a new easing type to your
.animate()
call: http://jsfiddle.net/jasper/EEtVs/1/I also changed the
top
value for the element you're animating because it only needs to be large enough to hide the element on page load.You can change the easing type by changing 'easeOutBounce' to any of the easing types on this page: http://gsgd.co.uk/sandbox/jquery/easing/
If you want to make sure your element is shown in browsers where JavaScript is turned off, run a script in the head of your page that adds a class to the HTML element like this:
Now you can make two versions of the CSS for the element you're bouncing into view:
This will set the top of the element to the top of the page unless JavaScript is enabled in which case the element will be hidden until the JavaScript runs and shows the element.