Hover on a component

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

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');
  }
});
1 Like

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.

2 Likes