Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 鼠标移动使div移动平缓_Javascript_Jquery_Css - Fatal编程技术网

Javascript 鼠标移动使div移动平缓

Javascript 鼠标移动使div移动平缓,javascript,jquery,css,Javascript,Jquery,Css,我试着让我的div平稳地倒转,并产生轻松的效果 当我将鼠标悬停在div上时,我希望图像能够平稳地从鼠标上移开,就像他们在网站第一部分中处理两个玩具的图像一样 我检查了他们的代码,没有找到我的答案 你们谁能提供 我已经设法用下面的代码对图像进行了稍微粗略的移动。也是一个。更最小化 答复 这个插件帮助我实现了我的目标 HTML 尝试在第358行使用.css而不是.offset 因此,来自: $(target).offset({ top: y ,left : x }); 致: 整体效果要平滑得多。代

我试着让我的div平稳地倒转,并产生轻松的效果

当我将鼠标悬停在div上时,我希望图像能够平稳地从鼠标上移开,就像他们在网站第一部分中处理两个玩具的图像一样

我检查了他们的代码,没有找到我的答案

你们谁能提供

我已经设法用下面的代码对图像进行了稍微粗略的移动。也是一个。更最小化

答复 这个插件帮助我实现了我的目标

HTML

尝试在第358行使用.css而不是.offset

因此,来自:

$(target).offset({ top: y ,left : x });
致:


整体效果要平滑得多。代码笔。

我觉得你的图像移动得很平稳。有什么问题吗?ToyFights网站上的那个似乎有一种轻松的效果,这使它变得非常平滑。我建议您使用CSS转换来实现这一点,CSS转换允许轻松的效果,并且比JavaScript的效果简单得多。@ScottMarcus我试过了,但没有效果。然后,我认为您做得不好。
  $.fn.smoothWheel = function () {
        //  var args = [].splice.call(arguments, 0);
        var options = jQuery.extend({}, arguments[0]);
        return this.each(function (index, elm) {

            if(!('ontouchstart' in window)){
                container = $(this);
                container.bind("mousewheel", onWheel);
                container.bind("DOMMouseScroll", onWheel);
                currentY = targetY = 0;
                minScrollTop = container.get(0).clientHeight - container.get(0).scrollHeight;
                if(options.onRender){
                    onRenderCallback = options.onRender;
                }
                if(options.remove){
                    log("122","smoothWheel","remove", "");
                    running=false;
                    container.unbind("mousewheel", onWheel);
                    container.unbind("DOMMouseScroll", onWheel);
                }else if(!running){
                    running=true;
                    animateLoop();
                }

            }
        });
    };
$(target).offset({ top: y ,left : x });
$(target).css({ top: y ,left : x });