natural-gallery-js icon indicating copy to clipboard operation
natural-gallery-js copied to clipboard

gallery.removeEventListener

Open johtso opened this issue 2 years ago • 2 comments

There should probably be a removeEventListener function. Currently I have a listener that I only want to fire the first time the event happens (after the first image has loaded). It would be nice to be able to clean up after myself.

johtso avatar Apr 12 '22 23:04 johtso

Instead of removeEventListener, I'd recommend exposing the underlying options as seen below. That gives the possibility to use once, or signal which is the superior way to remove an event listener nowadays.

- public addEventListener(name: [...], callback: [...]): void {
-     this.elementRef.addEventListener(name, callback);
+ public addEventListener(name: [...], callback: [...], options?: AddEventListenerOptions): void {
+     this.elementRef.addEventListener(name, callback, options);

PowerKiKi avatar Apr 13 '22 08:04 PowerKiKi

@PowerKiKi even better! Thanks, I didn't know you could do all those things with options.

johtso avatar Apr 13 '22 11:04 johtso

Done in cb4149a5bd73605f1be547c4d494f69798e79fa6

PowerKiKi avatar Mar 31 '23 14:03 PowerKiKi