Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-cover-1.0.js

Код файла
Версия от 18.08.2026, 07:00:17 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
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
История файла и сравнение версий
  • 18.08.2026, 07:00:17 · 56c3b845
t_onFuncLoad('processYoutubeVideo', function () {
313 window.processYoutubeVideo(target, coverParams['cover-height']);
314 });
315 });
316 });
317 youTubeVideoObserver.observe(el);
318 } else {
319 t_cover__createYoutubeCover(el, coverParams['cover-height']);
320 window.addEventListener(
321 'scroll',
322 t_throttle(function () {
323 t_cover__createYoutubeCover(el, coverParams['cover-height']);
324 }, 100)
325 );
326 }
327}
328
329/**
330 * process HTML5 video, when it inside viewport
331 *
332 * @param {HTMLElement} el
333 * @param {Object} coverParams
334 * @param {Boolean} isFixedParallax
335 */
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;
342
343 var isHeightMoreVH = false;
344 if (isFixedParallax && (isMoreVH || isMoreWinHeight)) {
345 el.style.height = '100vh';
346 isHeightMoreVH = true;
347 }
348
349 var hasLoop = !coverParams['video-noloop'];
350 var isMuted = !coverParams['video-nomute'];
351
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);
359 });
360 });
361 htmlVideoObserver.observe(el);
362 } else {
363 t_cover__createHTMLVideoCover(el, coverParams, isHeightMoreVH, isFixedParallax, hasLoop, isMuted);
364 window.addEventListener(
365 'scroll',
366 t_throttle(function () {
367 t_cover__createHTMLVideoCover(el, coverParams, isHeightMoreVH, isFixedParallax, hasLoop, isMuted);
368 }, 100)
369 );
370 }
371
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;
382
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';
393 }
394 });
395}
396
397/**
398 * process Iframe video, when it inside viewport
399 *
400 * @param {HTMLElement} el - cover
Предыдущие 100 строкСледующие 100 строк