我在网站上使用的某些 Javascript 有问题。 目的是根据特定 div 的屏幕外观更改标题元素 css。 实际上它在桌面上完美运行!但不是在iPhone上... 我无法弄清楚它有什么问题...... 你能帮我理解这个吗? 非常感谢!
var isInViewport = function (elem) {
var bounding = elem.getBoundingClientRect();
return (
bounding.top >= 0 &&
bounding.left >= 0 &&
bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
bounding.right <= (window.innerWidth || document.documentElement.clientWidth)
);
};
var section_clouds = document.querySelector('#section_intro_clouds');
window.addEventListener('transitionend', function (event) {
if (isInViewport(section_clouds)) {
document.getElementById('header_blanc').classList.add('colorer_bleu');}
else {document.getElementById('header_blanc').classList.remove('colorer_bleu');}
}, false);