1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-14 10:00:53 +00:00

Add support for clickable stream metadata. Add helper utility for detecting clicks outside of elements. Add support for manually shown/hidden tooltips, which is used for custom pop-ups.

This commit is contained in:
SirStendec 2017-12-04 18:58:19 -05:00
parent dfa0c9c88f
commit e224800fb9
7 changed files with 241 additions and 36 deletions

View file

@ -146,4 +146,26 @@ export class ManagedStyle {
this._blocks[key] = null;
}
}
}
export class ClickOutside {
constructor(element, callback) {
this.el = element;
this.cb = callback;
this._fn = this.handleClick.bind(this);
document.documentElement.addEventListener('click', this._fn);
}
destroy() {
if ( this._fn )
document.documentElement.removeEventListener('click', this._fn);
this.cb = this.el = this._fn = null;
}
handleClick(e) {
if ( ! this.el.contains(e.target) )
this.cb(e);
}
}