Hover on a component


#1

Hi there! How you check hover on a component? It is action?


#2

I dont belive there is support for hover out-of-the box. You should subscribe to hover event using jquery on didInsertElement hook.

export default Ember.Component.extend({
  onHoverIn: function() {
    // Your code
  },

  onHoverOut: function() {
    // Your code
  },

  didInsertElement: function() {
    this.$().hover(this.onHoverIn.bind(this), this.onHoverOut.bind(this));
  },

  willDestroyElement: function() {
    this.$().off('mouseenter mouseleave');
  }
});

#3

Actually, mouseEnter and mouseLeave events are enabled by default on Ember components. Just call your handler with those exact names. You don’t need anything special.