@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
89 lines • 3.31 kB
JavaScript
import { BaseEventObject } from "@aurigma/design-atoms-model/EventObject";
var HoverHandler = /** @class */ (function () {
function HoverHandler(_eventManager) {
var _this = this;
this._eventManager = _eventManager;
this._currentPermanentHandler = null;
this._currentHandler = null;
this._hoverChangedEvent = new BaseEventObject();
this._onItemRemoved = function (e) {
var _a;
if (((_a = _this._currentHandler) === null || _a === void 0 ? void 0 : _a.item) === e.item)
_this.hide();
};
this._eventManager.addItemRemoved(this._onItemRemoved);
}
Object.defineProperty(HoverHandler.prototype, "hoverChanged", {
get: function () {
return this._hoverChangedEvent;
},
enumerable: true,
configurable: true
});
HoverHandler.prototype.hide = function () {
if (!this._currentHandler)
return;
this._currentHandler = null;
this._hoverChangedEvent.notify();
};
HoverHandler.prototype.showPermanent = function (handler) {
if (this._currentPermanentHandler === handler)
return;
this._currentPermanentHandler = handler;
this._hoverChangedEvent.notify();
};
HoverHandler.prototype.hidePermanent = function () {
if (!this._currentPermanentHandler)
return;
this._currentPermanentHandler = null;
this._hoverChangedEvent.notify();
};
HoverHandler.prototype.show = function (handler) {
if (handler === this._currentHandler)
return;
this._currentHandler = handler;
this._hoverChangedEvent.notify();
};
Object.defineProperty(HoverHandler.prototype, "currentHandler", {
get: function () {
return this._currentHandler;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HoverHandler.prototype, "label", {
get: function () {
if (!this._currentHandler)
return null;
return this._currentHandler.item.name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HoverHandler.prototype, "labelPermanent", {
get: function () {
if (!this._currentPermanentHandler)
return null;
if (this._currentPermanentHandler == this._currentHandler)
return null;
return this._currentPermanentHandler.item.name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HoverHandler.prototype, "rectanglePermanent", {
get: function () {
if (!this._currentPermanentHandler)
return null;
if (this._currentPermanentHandler === this._currentHandler)
return null;
var rectangles = this._currentPermanentHandler.getHighlightRectangles({ includeChildren: false, includeParent: true });
return rectangles[0];
},
enumerable: true,
configurable: true
});
return HoverHandler;
}());
export { HoverHandler };
//# sourceMappingURL=HoverHandler.js.map