Created
October 8, 2016 06:51
-
-
Save FrankM1/72ebf7f5bc61453a0c8abd7cd1628e3a to your computer and use it in GitHub Desktop.
Elementor hover intent for edit tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var EditToolsBehavior; | |
EditToolsBehavior = Marionette.Behavior.extend( { | |
initialize: function() { | |
this.listenTo( builder.channels.dataEditMode, 'switch', this.onEditModeSwitched ); | |
}, | |
onEditModeSwitched: function() { | |
var activeMode = builder.channels.dataEditMode.request( 'activeMode' ); | |
this.view.$el.removeClass( 'builder-element-tools-active', 'preview' === activeMode ); | |
}, | |
handleHover: function() { | |
var $this = this; | |
var hoverConfig = { | |
sensitivity: 1, // number = sensitivity threshold (must be 1 or higher) | |
interval: 10, // number = milliseconds for onMouseOver polling interval | |
timeout: 500, // number = milliseconds delay before onMouseOut | |
over: function() { | |
$this.view.$el.addClass( 'builder-element-tools-active' ); | |
}, | |
out: function() { | |
$this.view.$el.removeClass( 'builder-element-tools-active' ); | |
} | |
}; | |
$this.view.$el.hoverIntent(hoverConfig); | |
}, | |
onRender: function() { | |
this.onEditModeSwitched(); | |
this.handleHover(); | |
} | |
} ); | |
module.exports = EditToolsBehavior; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment