I am trying to add a glow effect using snap SVG. Unlike raphael.js
, I believe Snap
doesn't support glow by default. However, there is a shadow effect. I tried to apply the shadow using set interval so that it mimics the behavior of a glow. But it is not working as it is intended to work. I want the shadow to fade-in and out say for 4-5 times making it loo like a glow. Here I invoke the shadow but it remains there irrespective of adding it to a setinterval
code. Here is the JS FIDDLE
CODE
var s = Snap("#main");
var thinkers = s.select("#lastImage");
var light = s.select("#look2");
// setinterval with counter
function setIntervalX(callback, delay, repetitions) {
var x = 0;
var intervalID = window.setInterval(function () {
callback();
if (++x === repetitions) {
window.clearInterval(intervalID);
}
}, delay);
}
// function to add glow
function addShadow() {
var f = s.filter(Snap.filter.shadow(2, 2, 10, "#ffffff"));
light.attr({
filter: f
});
}
// remove glow/shadow
function removeShadow() {
var k = s.filter(Snap.filter.shadow(0, 0, 0, "#ffffff"));
light.attr({
filter: k
});
}
setTimeout(shadow, 500)
function shadow() {
setIntervalX(addShadow, 1000, 4);
}