I've created this site on webflow: https://flumes-fantastic-site.webflow.io/ with the help of the jquery ripples library and I'm trying to make the automatic drops start when I load the page, as of now, I have to go to another tab and come back to it so it can start playing.
I'm new to coding so I'm probably messing up here with the code. This is what a friend from the stackoverflow (Daniels118) helped me piece together:
<script src="https://cdn.jsdelivr.net/npm/jquery.ripples@0.6.3/dist/jquery.ripples.min.js"></script>
<script>
$('#ripple').ripples({
resolution: 512,
dropRadius: 30,
perturbance: 0.04,
});
function randomDrop() {
var $el = $('#ripple');
var x = Math.random() * $el.outerWidth();
var y = Math.random() * $el.outerHeight();
var dropRadius = 30;
var strength = 0.04 + Math.random() * 0.04;
$el.ripples('drop', x, y, dropRadius, strength);
}
$(function() {
$("#ripple").focus();
});
$(function() {
$('#ripple').ripples({
resolution: 512,
dropRadius: 30,
perturbance: 0.04
});
var timer = null;
$(window).focus(function() {
if (timer === null) {
//console.log('on');
timer = setInterval(randomDrop, 1000);
}
})
.blur(function() {
if (timer !== null) {
clearInterval(timer);
timer = null;
//console.log('off');
}
})
.focus();
});
</script>
I appreciate any feedback. Thank you!