UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

52 lines 2.71 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2007-2018 GoodData Corporation var React = require("react"); var MenuPosition_1 = require("../positioning/MenuPosition"); var MenuOpenedByHover = /** @class */ (function (_super) { __extends(MenuOpenedByHover, _super); function MenuOpenedByHover() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.timerCloseDelay = null; _this.clearCloseDelayTimer = function () { window.clearTimeout(_this.timerCloseDelay); }; _this.hoverStart = function () { _this.clearCloseDelayTimer(); _this.timerCloseDelay = window.setTimeout(function () { _this.props.onOpenedChange({ opened: true, source: "HOVER_TIMEOUT" }); }, MenuOpenedByHover.openCloseDelayMs); }; _this.hoverEnd = function () { _this.clearCloseDelayTimer(); _this.timerCloseDelay = window.setTimeout(function () { _this.props.onOpenedChange({ opened: false, source: "HOVER_TIMEOUT" }); }, MenuOpenedByHover.openCloseDelayMs); }; return _this; } MenuOpenedByHover.prototype.componentWillUnmount = function () { this.clearCloseDelayTimer(); }; MenuOpenedByHover.prototype.render = function () { return (React.createElement(MenuPosition_1.default, { toggler: React.createElement("div", { onMouseEnter: this.hoverStart, onMouseLeave: this.hoverEnd }, this.props.toggler), togglerWrapperClassName: this.props.togglerWrapperClassName, opened: this.props.opened, topLevelMenu: this.props.topLevelMenu, alignment: this.props.alignment, spacing: this.props.spacing, offset: this.props.offset, portalTarget: this.props.portalTarget }, React.createElement("div", { onMouseEnter: this.hoverStart, onMouseLeave: this.hoverEnd }, this.props.children))); }; MenuOpenedByHover.openCloseDelayMs = 200; return MenuOpenedByHover; }(React.Component)); exports.default = MenuOpenedByHover; //# sourceMappingURL=MenuOpenedByHover.js.map