Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function soundwaveInit() {
- var wrap = document.getElementById('soundwave');
- var windowWidth = (window.innerWidth > 1920 ? 1920 : window.innerWidth);
- var barWidth = 1;
- var barSpaceBetween = 2;
- var barCount = Math.round(windowWidth / (barWidth + barSpaceBetween));
- var nodeBar;
- wrap.style.width = windowWidth + 'px';
- wrap.style.left = '50%';
- wrap.style.marginLeft = -(windowWidth / 2) + 'px';
- for (var i = 0; i < barCount; i++) {
- if ( barCount > parseInt(windowWidth) / 2 ) {
- var animationDur = Math.floor((Math.random() * 10) + i / 1000) + 's';
- var animationDel = '0.' + Math.floor((Math.random() * 5) + i) + 's';
- } else {
- var animationDur = Math.floor((Math.random() * 5)) + 's';
- var animationDel = '0.' + Math.floor((Math.random() * 10)) + 's';
- }
- nodeBar = document.createElement("div");
- nodeBar.classList.add('bar');
- wrap.append(nodeBar);
- nodeBar.style.animationDuration = animationDur;
- nodeBar.style.animationDelay = animationDel;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement