如何使用jquery使图像在圆形路径中移动? [英] How to make an image move in a circular path using jquery?

查看:81
本文介绍了如何使用jquery使图像在圆形路径中移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我尝试使图像沿圆形路径移动,但不沿圆形路径移动..我已经尝试过这样

Here i am trying to make an image move in a circular path but it is not moving in a circular path..I have tried like this Moving a picture around slowly

CSS

#friends { position: absolute; }

标记

<img src="http://jsfiddle.net/img/logo.png" 
id="friends"/>

JS

function moveit() {

    var newTop = Math.floor(Math.random()*350);
    var newLeft = Math.floor(Math.random()*1024);
    var newDuration = Math.floor(Math.random()*5000);

    $('#friends').animate({
      top: newTop,
      left: newLeft,
      }, newDuration, function() {
        moveit();
      });

}

$(document).ready(function() {
    moveit();
});

实时演示: http://jsfiddle.net/W69s6/embedded/result/

任何建议?

推荐答案

另一个变体(基于 演示: http://jsfiddle.net/W69s6/20/

这篇关于如何使用jquery使图像在圆形路径中移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆