Last active
April 6, 2016 09:06
-
-
Save sairion/4a6f73f0a1f7945ca0e46158f5a3b7ea to your computer and use it in GitHub Desktop.
native-mixed-click.js
This file contains 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
// To make the most of native browser click event | |
// Util.js | |
export function isPlainLeftClick(event) { | |
return !(event.button !== 0 || event.altKey || event.metaKey || event.ctrlKey || event.shiftKey); | |
} | |
// index.js | |
import { isPlainLeftClick } from 'Util'; | |
el.on('click', event => { | |
if (isPlainLeftClick(event)) { | |
event.preventDefault(); | |
transition($el.attr('href')); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment