UNPKG

@txdfe/at

Version:

一个设计体系组件库

30 lines (29 loc) 752 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.attach = void 0; /* eslint-disable import/prefer-default-export */ var attach = exports.attach = function attach(el, style, duration) { var ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; return new Promise(function (resolve, reject) { var id = window.setTimeout(function () { if (el) { if (style) { el.setAttribute('style', style); } else { el.removeAttribute('style'); } resolve(); } else { reject(); } }, duration); ref.cancel = function () { window.clearTimeout(id); reject({ canceled: true }); }; }); };