| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
function reducedMotion() { |
| 5 |
return window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; |
| 6 |
} |
| 7 |
|
| 8 |
function init() { |
| 9 |
if (reducedMotion()) return; |
| 10 |
|
| 11 |
var imgs = document.querySelectorAll('.bkim-img[data-hover]'); |
| 12 |
imgs.forEach(function (img) { |
| 13 |
var scale = parseFloat(img.dataset.scale) || 108; |
| 14 |
var hover = img.dataset.hover; |
| 15 |
|
| 16 |
// Set CSS custom property so CSS calc() can use the dynamic scale |
| 17 |
img.style.setProperty('--bkim-scale', scale); |
| 18 |
|
| 19 |
if (hover === 'none') { |
| 20 |
img.style.transition = 'none'; |
| 21 |
} |
| 22 |
}); |
| 23 |
} |
| 24 |
|
| 25 |
if (document.readyState === 'loading') { |
| 26 |
document.addEventListener('DOMContentLoaded', init); |
| 27 |
} else { |
| 28 |
init(); |
| 29 |
} |
| 30 |
|
| 31 |
}()); |
| 32 |
|