如何使用 jquery 不断旋转对象?

发布于 2024-10-18 01:46:53 字数 281 浏览 2 评论 0原文

好的!情况是这样的。我有一个 jQuery 插件,它可以在我的标题中设置背景图像的动画,以不断从左到右滚动。我在此标题上放置了一个 .png 轮子。我需要让轮子随着移动的背景不断旋转。

CSS3 - 是的,我可以使用 CSS3,但是一些使用 Internet Explorer 的可怜人会在移动的背景上看到一个固定的轮子,这会很奇怪。

jQuery 插件 - 这是我想使用的插件,但我还没有找到一个可以不断旋转图像的插件。当您激活它时,大多数只会旋转一定角度。

如果有人有任何想法,我将不胜感激!

OKAY! Here's the situation. I've got a jQuery plugin that's animating a background-image in my header to constantly scroll left-to-right. I have a .png of a wheel sitting on this header. I need to have the wheel constantly spinning with the moving background.

CSS3- Yes I could use CSS3, but then some poor soul using Internet Explorer would see a stationary wheel on a moving background which would be weird.

jQuery Plugins- This is what I'd LIKE to use, but I have yet to find one that will constantly rotate the image. Most only rotate by a certain angle when you activate it.

If anybody has any thoughts, I'd appreciate it!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

無心 2024-10-25 01:46:54

@dietbacon 问如何停止轮换。由于我还不能发表评论,我就在这里回答。

this 答案中,我编写了一个函数,该函数在给定元素中进行无限旋转并且可以取消。

@dietbacon asked how to stop a rotation. Since I cannot yet comment, I will answer here.

In this answer, I wrote a function that does an infinite rotation in a given element and that can be cancelled.

镜花水月 2024-10-25 01:46:53

您可以尝试以下操作:

http://code.google.com/p/jqueryrotate/wiki/Examples

    var rotation = function (){
   $("#img").rotate({
      angle:0, 
      animateTo:360, 
      callback: rotation,
      easing: function (x,t,b,c,d){        // t: current time, b: begInnIng value, c: change In value, d: duration
          return c*(t/d)+b;
      }
   });
}
rotation();

You could try this:

http://code.google.com/p/jqueryrotate/wiki/Examples

    var rotation = function (){
   $("#img").rotate({
      angle:0, 
      animateTo:360, 
      callback: rotation,
      easing: function (x,t,b,c,d){        // t: current time, b: begInnIng value, c: change In value, d: duration
          return c*(t/d)+b;
      }
   });
}
rotation();
变身佩奇 2024-10-25 01:46:53

它本身不是 jQuery,但如果您想在 JavaScript 中不断执行某些操作,请使用 setInterval(),如下所示:

setInterval("alert('Rotate!');", 100);

但将警报替换为轮换代码,间隔以毫秒为单位。

It's not jQuery as such, but if you want to do something constantly in JavaScript, use setInterval(), like so:

setInterval("alert('Rotate!');", 100);

But replace the alert with your rotation code, and the interval is in milliseconds.

迷爱 2024-10-25 01:46:53

看起来您想要这个关于旋转图像的相关问题的答案使用 jQuery...

但它纯粹是一个旋转轮,那么两帧或三帧动画 gif 可能会更容易、更快、CPU 占用更少...

It looks like you want this answer to a related question about rotating images with jQuery...

But it's purely a rotating wheel, then a two or three frame animated gif will probably be easier, faster, and less CPU-intensive...

枫林﹌晚霞¤ 2024-10-25 01:46:53

您可以使用 jquery 插件来旋转图像(如 3D 对象):

pic360 插件

You can use jquery plugin for rotating image like 3d object:

pic360 plugin

苏璃陌 2024-10-25 01:46:53

我为此创建了一个插件,它也适用于 Internet Explorer 7 和 8!
在这里:http://wp-dreams.com/jquery-element-rotation-插件/

I have created a plugin for this, which works with internet explorer 7 and 8 as well!
Here you go: http://wp-dreams.com/jquery-element-rotation-plugin/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文