How to apply a motion-blur in javascript/jquery? [duplicate]

喜夏-厌秋 提交于 2019-12-04 12:16:11

You can use absolute positioning and opacity to create blur effects by stacking the same image on top of itself. Here's a quick demo, it's probably not the effect you want but it can get ya started:

$('img').on('mouseenter', function () {

    var $theClone = $(this).clone().css({ opacity : 0.5, position : 'absolute', top : 0 });

    $(this).parent().append($theClone);

    $theClone.animate({ left : 10 }, 500).on('mouseleave', function () {
        $(this).stop().fadeOut(250, function () {
            $(this).remove();
        });
    });      
});​

This creates a clone of the image once you mouse-over it, then the clone animates to a blur and when you mouse-out the cloned image, it fades-out and is removed from the DOM.

Here is a demo: http://jsfiddle.net/mbFTk/93/

A pure javascript solution is not that easy to implement, you could give a try to this library anyway:

http://www.pixastic.com/lib/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!