Execute SVG html code every 10 seconds

Viewed 136

I've used an html code to make a text glitch on a website, however I need to only make the animation glitch happen every 10 seconds as it's a little crazy at the moment.

Where I'm stuck is how to re-execute the html code using a JS setInterval(html, 10000). Is this even possible? Thanks!

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg">
<script>
    var html = '<defs>';
    html += '<filter id="glitch" x="0" y="0">';
    html += '<feColorMatrix in="SourceGraphic" mode="matrix" values="1 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0" result="r" />';
    html += '<feOffset in="r" result="r" dx="-5">';
    html += '<animate attributeName="dx" attributeType="XML" values="0; -5; 0; -18; -2; -4; 0 ;-3; 0" dur="0.2s" repeatCount="indefinite" />';
    html += '</feOffset>';
    html += '<feColorMatrix in="SourceGraphic" mode="matrix" values="0 0 0 0 0  0 1 0 0 0  0 0 0 0 0  0 0 0 1 0" result="g"/>';
    html += '<feOffset in="g" result="g" dx="-5" dy="1">';
    html += '<animate attributeName="dx" attributeType="XML" values="0; 0; 0; -3; 0; 8; 0 ;-1; 0" dur="0.15s" repeatCount="indefinite" />';
    html += '</feOffset>';
    html += '<feColorMatrix in="SourceGraphic" mode="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 1 0 0  0 0 0 1 0" result="b"/>';
    html += '<feOffset in="b" result="b" dx="5" dy="2">'
    html += '<animate attributeName="dx" attributeType="XML" values="0; 3; -1; 4; 0; 2; 0 ;18; 0" dur="0.35s" repeatCount="indefinite"/>';
    html += '</feOffset>';
    html += '<feBlend in="r" in2="g" mode="screen" result="blend" />';
    html += '<feBlend in="blend" in2="b" mode="screen" result="blend" />';
    html += '</filter>';
    html += '</defs>';
</script></svg>
1 Answers
Related