Ember-responds-to
This Ember CLI addon makes it easy to handle browser events in your components.
- resize and orientationchange events trigger
resize
and callresize
. - scroll events trigger
scroll
and callscroll
. - enter keydown events trigger
enterKeydown
and callenterKeydown
. - esc keydown events trigger
escKeydown
and callescKeydown
. - print events trigger
print
and callprint
.
The scroll and resize events are debounced using requestAnimationFrame
.
The enter and esc keydown event handlers are called in LIFO order and each can stop "propagation" with a truthy return value.
The print event is detected with matchMedia
so does not support IE9 and below (see http://caniuse.com/#feat=matchmedia for browser support).
Usage
Install the addon.
ember install ember-responds-to
Import the mixins in a component and use the events or the handlers.
;;;;;;; ;
In CI
If you use phantomjs
for testing you need to include a polyfill for requestAnimationFrame
. To do so, add the file at https://gist.github.com/paulirish/1579671 to vendor/
and add the following line to your ember-cli-build.js
.
app.import('vendor/rAF.js', { type: 'test' });