UNPKG

react-elegant-ui

Version:

Elegant UI components, made by BEM best practices for react

38 lines (37 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.patchScaleFactor = void 0; // Imported from yandex-ui. Source: https://github.com/bem/yandex-ui/ function hasTransformScale(element) { return window.getComputedStyle(element).transform.indexOf('matrix') !== -1; } function patchScaleFactorFn(_a) { var state = _a.state, instance = _a.instance, options = _a.options; var reference = state.elements.reference; var _b = options.delay, delay = _b === void 0 ? 200 : _b; if (!instance.__patchedScaleFactor) { instance.__patchedScaleFactor = true; // Force update only if reference is have transforms if (reference instanceof HTMLElement && hasTransformScale(reference)) { // Update after delay to await end of animations setTimeout(function () { return instance.update(); }, delay); } } } /** * Modifier to correction a position of reference with consider a transforms */ var patchScaleFactor = exports.patchScaleFactor = { name: 'patchScaleFactor', enabled: true, fn: patchScaleFactorFn, phase: 'beforeRead', requires: ['popperOffsets'] };