Motion blur (pronounced: motion blur ) - blur the image when you play motion scenes or fast moving objects.
')
- Motion blur on Wikipedia
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="filters"> <defs> <filter id="blur"> <feGaussianBlur in="SourceGraphic" stdDeviation="0,0" /> </filter> </defs> </svg>
.selector{ -webkit-filter: url("#blur"); filter: url("../index.html#blur"); }
var filters = document.querySelector(".filters"), // SVG, defs = filters.querySelector("defs"), // SVG blur = defs.querySelector("#blur"), // blurFilter = blur.firstElementChild; // feGaussianBlur
blurFilter.setAttribute("stdDeviation","12,0");
<filter>
element for each new object to which we want to apply a filter. Here is an easy way to create these filters dynamically: // , $(".js-blur").each(function(i){ // var blurClone=blur.cloneNode(true); // ID, CSS var blurId="blur"+i; blurClone.setAttribute("id",blurId); defs.appendChild(blurClone); // CSS var filter="url(#"+blurId+")"; $(this) .css({ webkitFilter:filter, filter:filter }) // .data("blur",blurClone) ; });
// , var $element=$(".selector"); // , var lastPos=$element.offset(); // var multiplier=0.25; // function setBlur(x,y){ blurFilter.setAttribute("stdDeviation",x+","+y); } (function updateMotionBlur(){ // var currentPos=$element.offset(); // var xDiff=Math.abs(currentPos.left-lastPos.left)*multiplier; var yDiff=Math.abs(currentPos.top-lastPos.top)*multiplier; // setBlur(xDiff,yDiff); // lastPos=currentPos; // requestAnimationFrame(updateMotionBlur); })();
Source: https://habr.com/ru/post/255423/
All Articles