UNPKG

@yandex/ui

Version:

Yandex UI components

29 lines (28 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.patchScaleFactor = void 0; /** * Модификатор, исправляющий положение попапа с учетом scale-трансформации якоря. */ exports.patchScaleFactor = { name: 'patchScaleFactor', enabled: true, fn: patchScaleFactorFn, phase: 'beforeRead', requires: ['popperOffsets'], }; function patchScaleFactorFn(_a) { var state = _a.state, instance = _a.instance; var reference = state.elements.reference; if (!instance.__patchedScaleFactor) { instance.__patchedScaleFactor = true; // Вызываем обновление только в случае если у якоря есть трансформация. if (reference instanceof HTMLElement && hasTransformScale(reference)) { // Устанавливаем задержку в 200ms для ожидания завершения большинства анимаций. setTimeout(function () { return instance.update(); }, 200); } } } function hasTransformScale(element) { return window.getComputedStyle(element).transform.indexOf('matrix') !== -1; }