Каталог файловtilda-cover-1.0.js
301 *302 * @param {HTMLElement} el - cover303 * @param {Object} coverParams304 */305function t_cover__processYouTubeVideo(el, coverParams) {306 if ('IntersectionObserver' in window) {307 var youTubeVideoObserver = new IntersectionObserver(function (entries, youTubeVideoObserver) {308 entries.forEach(function (entry) {309 if (!entry.isIntersecting) return;310 var target = entry.target;311 youTubeVideoObserver.unobserve(target);312
История файла и сравнение версий
t_onFuncLoad('processYoutubeVideo', function () {
313 window.processYoutubeVideo(target, coverParams['cover-height']); 317 youTubeVideoObserver.observe(el); 319 t_cover__createYoutubeCover(el, coverParams['cover-height']); 320 window.addEventListener( 322 t_throttle(function () { 323 t_cover__createYoutubeCover(el, coverParams['cover-height']); 330 * process HTML5 video, when it inside viewport 332 * @param {HTMLElement} el 333 * @param {Object} coverParams 334 * @param {Boolean} isFixedParallax 336function t_cover__processHTML5Video(el, coverParams, isFixedParallax) { 337 el.style.backgroundSize = 'auto'; 338 var isHeightInVH = coverParams['cover-height'].indexOf('vh') !== -1; 339 var isMoreVH = isHeightInVH ? parseInt(coverParams['cover-height'], 10) > 100 : false; 340 var isHeightInPX = coverParams['cover-height'].indexOf('px') !== -1; 341 var isMoreWinHeight = isHeightInPX ? parseInt(coverParams['cover-height'], 10) > window.innerHeight : false; 343 var isHeightMoreVH = false; 344 if (isFixedParallax && (isMoreVH || isMoreWinHeight)) { 345 el.style.height = '100vh'; 346 isHeightMoreVH = true; 349 var hasLoop = !coverParams['video-noloop']; 350 var isMuted = !coverParams['video-nomute']; 352 if ('IntersectionObserver' in window) { 353 var htmlVideoObserver = new IntersectionObserver(function (entries, htmlVideoObserver) { 354 entries.forEach(function (entry) { 355 if (!entry.isIntersecting) return; 356 var target = entry.target; 357 htmlVideoObserver.unobserve(target); 358 t_cover__createAndProcessHTML5Video(target, coverParams, hasLoop, isMuted); 361 htmlVideoObserver.observe(el); 363 t_cover__createHTMLVideoCover(el, coverParams, isHeightMoreVH, isFixedParallax, hasLoop, isMuted); 364 window.addEventListener( 366 t_throttle(function () { 367 t_cover__createHTMLVideoCover(el, coverParams, isHeightMoreVH, isFixedParallax, hasLoop, isMuted); 372 // update html5 video styles, if it has fixed parallax, and it's height larger than viewport height 373 window.addEventListener('scroll', function () { 374 if (!isFixedParallax || !isHeightMoreVH) return; 375 var currentElementParent = el.parentElement; 376 var windowScrollTop = window.pageYOffset; 377 var windowHeight = window.innerHeight; 378 var windowBottomPos = windowScrollTop + windowHeight; 379 var parentHeight = t_cover__getPureHeight(currentElementParent); 380 var parentTopPos = currentElementParent.getBoundingClientRect().top + windowScrollTop; 381 var parentBottomPos = parentTopPos + parentHeight; 383 if (windowBottomPos >= parentBottomPos) { 384 el.style.position = 'absolute'; 385 el.style.bottom = '0px'; 386 el.style.top = 'auto'; 387 } else if (windowScrollTop >= parentTopPos) { 388 el.style.position = 'fixed'; 389 el.style.top = '0px'; 390 } else if (windowScrollTop < parentTopPos) { 391 el.style.position = 'relative'; 392 el.style.top = 'auto'; 398 * process Iframe video, when it inside viewport 400 * @param {HTMLElement} el - cover