back

Emitter

This tiny event emitter handles luge internal events. You can subscribe to luge events or add your own ones.

Usage

const myCallback = () => { ... }

luge.emitter.on('my-event', myCallback , this)
luge.emitter.once('my-event', myCallback , this)
luge.emitter.off('my-event', myCallback )

luge.emitter.emit('my-event')

Events

  • mouseMove(e): emitted when the mouse move, synced with the window mousemove event. The MouseEvent object is passed as a paramater ;
  • pageTransition(html): emitted during pages transition, just after the new page has been added to dom. The html of the new page is passed as a parameter ;
  • resize: emitted on window resize with a 200ms delay for optimization ;
  • scroll: emitted on scroll, synced with the window scroll event or with requestAnimationFrame when smooth scroll is used ;
  • scrollStart: emitted when scroll starts ;
  • scrollEnd: emitted when scroll ends ;

Methods

on(name, callback, context, once)

Attach a function to an event.

Parameter Type Description
name String Event name.
callback Function Function to call.
context Object Context.
once Boolean Call function only once.

once(name, callback, context)

Attach a function to an event only once.

Parameter Type Description
name String Event name.
callback Function Function to call.
context Object Context.

emit(name)

Emit an event.

Parameter Type Description
name String Event name.

off(name, callback)

Detach a function from an event.

Parameter Type Description
name String Event name.
callback Function Function that was attached.