Created
April 24, 2024 07:23
-
-
Save Kcko/b4f79d3d063b85c1168187f6cc9eeaca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
constructor(el, options) { | |
this.el = el; | |
const defaultOptions = { | |
onHover: (element, e) => { | |
console.log(':)))', element, e); | |
}, | |
}; | |
this.options = { ...defaultOptions, ...options }; | |
this.mouseOverHandler = this.handleMouseOver.bind(this); // Vytvoření odkazu na metodu handleMouseOver | |
} | |
init() { | |
this.el.addEventListener('mouseover', this.mouseOverHandler); // Přidání posluchače události | |
} | |
destroy() { | |
this.el.removeEventListener('mouseover', this.mouseOverHandler); // Odstranění posluchače události | |
} | |
handleMouseOver(e) { | |
if (this.options.onHover) { | |
this.options.onHover(this.el, e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment