Webkit Backdrop Filter with JavaScript cross-browser

Viewed 7202

I have seen this amazing demo of the new

-webkit-backdrop-filter: blur(Xpx);

and I would like to ask how to reproduce this with JavaScript that at least works in Chrome but possibly in Firefox too?

The Demo: https://webkit.org/demos/backdrop-filter/

1 Answers

You could try svg filters:

http://codepen.io/MakiBM/pen/YGEgQK?editors=1000

<svg x="0px" y="0px" width="500px" height="500px" viewbox="0 0 500 500">
  <defs>
    <filter id="blur" x="0%" y="0%" height="100%" width="100%" primitiveUnits="userSpaceOnUse">
      <feGaussianBlur x="50" y="50" width="400" height="400" stdDeviation="10" in="SourceGraphic" result="blurImg"/>
      <feComponentTransfer in="blurImg" result="opaqueBlur">
        <feFuncA type="linear" intercept="1"/>
      </feComponentTransfer>
      <feBlend mode="normal" in="opaqueBlur" in2="SourceGraphic"/>
    </filter>
  </defs>

   <image filter="url(#blur)" x="10" y="10" id="svg-image" width="100%" height="100%" xlink:href="https://www.nycgovparks.org/photo_gallery/full_size/14413.jpg" />

    <rect x="50" y="50" height="400" width="400" fill="rgb(255,255,255)" fill-opacity="0.2" />
</svg>

I haven't go round with crossbrowser check but support is very wide: http://caniuse.com/svg-filters

Related