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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-zoom-2.0.js

Код файла
Версия от 04.12.2026, 04:03:54 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
1401	const topCoord = (window.innerHeight - zoomedImage.offsetHeight) / 2;1402	let clientYpercent;1403	let imageYpx;1404	let clientXpercent;1405	let imageXpx;1406 1407	const naturalWidth = zoomedImage.getAttribute('data-original-svg-width') || zoomedImage.naturalWidth;1408	const naturalHeight = zoomedImage.getAttribute('data-original-svg-height') || zoomedImage.naturalHeight;1409 1410	zoomedImage.style.left = `${leftCoord}px`;1411	zoomedImage.style.top = `${topCoord}px`;1412
История файла и сравнение версий
  • 04.12.2026, 04:03:54 · 56c3b845
1413 if (window.innerWidth < naturalWidth && window.innerHeight < naturalHeight) {
1414 clientXpercent = (event.clientX * 100) / window.innerWidth;
1415 imageXpx = -(clientXpercent * (naturalWidth - window.innerWidth)) / 100;
1416 clientYpercent = (event.clientY * 100) / window.innerHeight;
1417 imageYpx = -(clientYpercent * (naturalHeight - window.innerHeight)) / 100;
1418
1419 zoomedImage.style.left = `${imageXpx}px`;
1420 zoomedImage.style.top = `${imageYpx}px`;
1421
1422 if (isMobile) {
1423 zoomedImage.ontouchmove = e => {
1424 imageMoveWidth(e, zoomedImage);
1425 imageMoveHeight(e, zoomedImage);
1426 };
1427 } else {
1428 zoomedImage.onmousemove = e => {
1429 imageMoveWidth(e, zoomedImage);
1430 imageMoveHeight(e, zoomedImage);
1431 };
1432 }
1433 } else if (window.innerWidth < naturalWidth) {
1434 clientXpercent = (event.clientX * 100) / window.innerWidth;
1435 imageXpx = -(clientXpercent * (naturalWidth - window.innerWidth)) / 100;
1436
1437 zoomedImage.style.left = `${imageXpx}px`;
1438
1439 if (isMobile) {
1440 zoomedImage.ontouchmove = e => {
1441 imageMoveWidth(e, zoomedImage);
1442 };
1443 } else {
1444 zoomedImage.onmousemove = e => {
1445 imageMoveWidth(e, zoomedImage);
1446 };
1447 }
1448 } else if (window.innerHeight < naturalHeight) {
1449 clientYpercent = (event.clientY * 100) / window.innerHeight;
1450 imageYpx = -(clientYpercent * (naturalHeight - window.innerHeight)) / 100;
1451
1452 zoomedImage.style.top = `${imageYpx}px`;
1453
1454 if (isMobile) {
1455 zoomedImage.ontouchmove = e => {
1456 imageMoveHeight(e, zoomedImage);
1457 };
1458 } else {
1459 zoomedImage.onmousemove = e => {
1460 imageMoveHeight(e, zoomedImage);
1461 };
1462 }
1463 }
1464
1465 function imageMoveWidth(e, img) {
1466 clientXpercent = ((e.touches !== undefined ? e.touches[0].clientX : e.clientX) * 100) / window.innerWidth;
1467 imageXpx = -(clientXpercent * (img.offsetWidth - window.innerWidth)) / 100;
1468 img.style.left = `${imageXpx}px`;
1469 }
1470
1471 function imageMoveHeight(e, img) {
1472 clientYpercent = ((e.touches !== undefined ? e.touches[0].clientY : e.clientY) * 100) / window.innerHeight;
1473 imageYpx = -(clientYpercent * (img.offsetHeight - window.innerHeight)) / 100;
1474 img.style.top = `${imageYpx}px`;
1475 }
1476}
1477
1478/**
1479 * @param {HTMLElement} zoomedImage
1480 */
1481function t_zoom_mobileZoomPositioningInit(zoomedImage) {
1482 const leftCoordinate = (window.innerWidth - zoomedImage.offsetWidth) / 2;
1483 const topCoordinate = (window.innerHeight - zoomedImage.offsetHeight) / 2;
1484
1485 zoomedImage.style.left = `${leftCoordinate}px`;
1486 zoomedImage.style.top = `${topCoordinate}px`;
1487
1488 const currentPosition = {
1489 x: 0,
1490 y: 0,
1491 };
1492
1493 let startTouchPosition = {};
1494 let currentTranslate = {};
1495
1496 zoomedImage.ontouchstart = e => {
1497 startTouchPosition = t_zoom_getTouchEventXY(e);
1498 };
1499 zoomedImage.ontouchmove = e => {
1500 const currentTouchPosition = t_zoom_getTouchEventXY(e);
Предыдущие 100 строкСледующие 100 строк