How to reveal part of blurred image where mouse is hovered?

后端 未结 5 1872
别跟我提以往
别跟我提以往 2020-12-13 07:41

How to reveal part(small portion) of blurred image where mouse is hovered??Currently it blurs whole image but I want the part of the blurred image where the mouse i

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 08:12

    I just want to post an alternative solution. It doesn't have great browser support as it is built on SVG images, masks and filters. I have tested and it works in Chrome 33, Safari 6.1.1 and Firefox 25.0.1.

    Let me know what you think: jsFiddle

    New version with inverted mask for blurred image jsFiddle

    HTML + SVG

    CSS

    body {
        margin: 0;
    }
    .pic {
        text-align: center;
        position: relative;
        height: 250px;
    }
    .blur {
        height: 100%;
    }
    .overlay {
        position: absolute;
        top: 0px;
        left: 0px;
        height: 100%;
    }
    

    JavaScript

    $('.pic').mousemove(function (event) {
        event.preventDefault();
        var upX = event.clientX;
        var upY = event.clientY;
        var mask = $('#mask1 circle')[0];
        mask.setAttribute("cy", (upY - 5) + 'px');
        mask.setAttribute("cx", upX + 'px');
    });
    

提交回复
热议问题