| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
function reducedMotion() { |
| 5 |
return window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; |
| 6 |
} |
| 7 |
|
| 8 |
function initBlob(section) { |
| 9 |
var speed = parseFloat(section.dataset.speed) || 10; |
| 10 |
var paused = section.dataset.paused === 'true'; |
| 11 |
|
| 12 |
if (reducedMotion()) { |
| 13 |
// CSS handles it via @media, but also set JS flag |
| 14 |
section.setAttribute('data-paused', 'true'); |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
// Sync animation speed from data attribute to CSS custom property |
| 19 |
section.style.setProperty('--bkgb-speed', speed + 's'); |
| 20 |
|
| 21 |
if (paused) { |
| 22 |
section.setAttribute('data-paused', 'true'); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
function init() { |
| 27 |
document.querySelectorAll('.bkgb-section[data-speed]').forEach(initBlob); |
| 28 |
} |
| 29 |
|
| 30 |
if (document.readyState === 'loading') { |
| 31 |
document.addEventListener('DOMContentLoaded', init); |
| 32 |
} else { |
| 33 |
init(); |
| 34 |
} |
| 35 |
|
| 36 |
}()); |
| 37 |
|