使用jquery动画方法缩放图像

使用jquery动画方法缩放图像,jquery,image-scaling,Jquery,Image Scaling,我想像css3转换一样使用jquery缩放图像。 所以我在这里写了一个脚本 (function(){ $('.img_container img').on('mouseover',function(){ var $this = $(this), width = $this.attr('width'), height = $this.attr('height'), new_width = (width

我想像css3转换一样使用jquery缩放图像。 所以我在这里写了一个脚本

 (function(){
    $('.img_container img').on('mouseover',function(){
        var $this = $(this),
            width = $this.attr('width'),
            height = $this.attr('height'),
            new_width = (width + 10)+'px',
            new_height = (height + 10)+'px';

        $this.animate({'width':new_width,
                       'height':new_height,
                       'top':'-10px',
                       'left':'-10px'},{
                           duration:300,
                           });
        });
    })();
将鼠标移到图像上会使图像的宽度和高度增加10px以上,这是不寻常的 需要帮忙吗

我能写另一个剧本

(function(){
    var factor = 15;

$('.img_container img').on('mouseover',function(){

        var $this = $(this),
        height = $this.height(),
        width = $this.width();
    $(this).animate({
        top:  height - factor,
        left:  width - factor,
        width: width + factor,
        height: height +factor
    },200);
});
$('.img_container img').on('mouseleave',function(){

        var $this = $(this),
        height = $this.height(),
        width = $this.width();
    $(this).animate({
        top:  height + factor,
        left:  width + factor,
        width: width - factor,
        height: height - factor
    },200);
});

})();
但是,如果我在图像中来回移动鼠标数次 非常快,图像会“跳动”,因为它捕捉到每一个事件和事件
不能足够快地展示它们。这就像是动画的延迟。如何解决这个问题。

我的第一个猜测是使用

$(this).animate
$this.animate
而不是


我的第一个猜测是使用

$(this).animate
$this.animate
而不是

有关具体因素,请参阅本节


有关具体因素,请参阅此

@samthush然后接受并向其答案伴侣提供代表:]我这样做是因为我发现此解决方案很好。@samthush然后接受并向其答案伴侣提供代表:]我这样做是因为我发现此解决方案很好。