Giter VIP home page Giter VIP logo

blur-viewer's Introduction

Blur Viewer

About

image blur effect using svg filter

view the blurred image with mouse move

screen

Usage

  1. include the css and script
<link type="text/css" rel="stylesheet" href="../dist/blur-viewer.css">

<script type="text/javascript" src="../dist/blur-viewer.js"></script>
  1. add image wrapper and svg template in html with id 'blur-template'
  <div class="blur-wrapper"><img class="blur-image" src="./images/pic1.jpg" alt=""></div>

  <script type="text/template" id="blur-template">
    <svg class="blur" width="100%">

      <filter id="{{filter}}">
        <feGaussianBlur stdDeviation="10" color-interpolation-filters="sRGB"/>
      </filter>

      <mask class="mask" id="{{mask}}">
        <circle cx="-50%" cy="-50%" r="120" fill="white" filter="url(#{{filter}})" />
      </mask>

      <image xlink:href="{{image}}" width="100%" height="100%" filter="url(#{{filter}})" ></image>
      <image xlink:href="{{image}}" width="100%" height="100%" mask="url(#{{mask}})"></image>
    </svg>
  </script>
  1. call BlurViewer with new
let blurElements = document.querySelectorAll('.blur-wrapper');

if(blurElements) {
  for(let i=0;i<blurElements.length;i++) {
    let blurElement = blurElements[i]
    if('blurViewer' in blurElement) {
      blurElement.blurViewer.destroy();
    };
    blurElement.blurViewer = new dodoroy.BlurViewer(blurElement);
  }
}

Credit

Created by @dodo糯, blog

blur-viewer's People

Contributors

effy-yin avatar

Stargazers

 avatar  avatar

Watchers

 avatar

blur-viewer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.