Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-responds-to

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-responds-to

Ember mixins for browser event handling.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-92.31%
Maintainers
1
Weekly downloads
 
Created
Source

Ember-responds-to

This Ember CLI addon makes it easy to handle browser events in your components.

  • resize and orientationchange events trigger resize and call resize.
  • scroll events trigger scroll and call scroll.
  • enter keydown events trigger enterKeydown and call enterKeydown.
  • esc keydown events trigger escKeydown and call escKeydown.

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.

Usage

Install the addon.

ember install ember-responds-to

Import the mixins in a component and use the events or the handlers.

import Ember from 'ember';
import RespondsToEnterKeydown from 'ember-responds-to/mixins/responds-to-enter-keydown';
import RespondsToEscKeydown from 'ember-responds-to/mixins/responds-to-esc-keydown';
import RespondsToResize from 'ember-responds-to/mixins/responds-to-resize';
import RespondsToScroll from 'ember-responds-to/mixins/responds-to-scroll';

export default Ember.Component.extend(
  RespondsToEnterKeydown,
  RespondsToEscKeydown,
  RespondsToResize,
  RespondsToScroll,
{

  classNameBindings: [ 'isLandscape:landscape:portrait' ],

  enterKeydown: function () {
    this.sendAction('submit');
  },

  escKeydown: function () {
    this.sendAction('close');
  },

  logResize: function () {
    console.log('resize event triggered');
  }.on('resize'),

  logScroll: function () {
    console.log('scroll event triggered');
  }.on('scroll'),

  resize: () => console.log('resize handler called'),
  scroll: () => console.log('scroll handler called'),

  setLandscape: function () {
    this.set('isLandscape', window.innerWidth > window.innerHeight);
  }.on('didInsertElement', 'resize'),

});

Keywords

FAQs

Package last updated on 25 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc