;
disconnectedCallback() {
super.disconnectedCallback();
this._clearHideTimer();
}
private _clearHideTimer() {
if (this._hideTimer) {
clearTimeout(this._hideTimer);
this._hideTimer = undefined;
}
}
protected handleToggleReveal() {
if (this.noToggle) return;
this._clearHideTimer();
if (this.duration) {
this._isRevealed = true;
this._isToggled = true;
this.requestUpdate();
setTimeout(() => {
this._isRevealed = false;
this._isToggled = false;
this.requestUpdate();
}, this.duration);
} else {
this._isRevealed = !this._isRevealed;
this._isToggled = !this._isToggled;
this.requestUpdate();
}
}
protected handleMouseEnter() {
// handle hover only while hovered
this._clearHideTimer();
this._isRevealed = true;
this.requestUpdate();
}
protected handleMouseLeave() {
if (this._isToggled) return;
this._clearHideTimer();
this._hideTimer = setTimeout(() => {
this._hideTimer = undefined;
this._isRevealed = false;
this.requestUpdate();
}, this.hideDelay);
}
render() {
return html`
${this.initial}
${this.revealed}
`;
}
}