UNPKG

panel

Version:

Web Components with Virtual DOM: lightweight composable web apps

19 lines (17 loc) 632 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.delayedAttrRemove = delayedAttrRemove; /** * A simple remove hook generator so we remove an element after it's finished its closing animation. * The attr value is immediately set and after waitMs it's removed from dom. * @example hook={remove: $hooks.delayedAttrRemove(`open`, `false`)} */ function delayedAttrRemove(attr, value) { let waitMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500; return function (vnode, callback) { vnode.elm.setAttribute(attr, value); setTimeout(callback, waitMs); }; }