Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for hover trigger #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions _src/selectordie.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
linksExternal: false, // Boolean - false by default - Should the options be treated as links and open in a new window/tab?
size: 0, // Integer - 0 by default - The value set equals the amount of items before scroll is needed
tabIndex: 0, // integer - 0 by default
trigger: "click" // String - "click" by default - Supports "hover" action to open the SoD
onChange: $.noop // Adds a callback function for when the SoD gets changed
},
$_settings = {},
Expand Down Expand Up @@ -141,9 +142,14 @@
$select.appendTo( $sod );

// Bind events to the SoD
$sod.on("focusin", _private.focusSod)
.on("click", _private.triggerSod)
.on("click", ".sod_option", _private.optionClick)
if ($_settings.trigger === "hover") { // if trigger configuration is hover
$sod.on("mouseenter", _private.triggerSod)
.on("mouseleave", _private.triggerSod);
} else {
$sod.on("focusin", _private.focusSod)
.on("click", _private.triggerSod);
}
$sod.on("click", ".sod_option", _private.optionClick)
.on("mousemove", ".sod_option", _private.optionHover)
.on("keydown", _private.keyboardUse);

Expand Down