Skip to content

Instantly share code, notes, and snippets.

@sairion
Last active April 6, 2016 09:06
Show Gist options
  • Save sairion/4a6f73f0a1f7945ca0e46158f5a3b7ea to your computer and use it in GitHub Desktop.
Save sairion/4a6f73f0a1f7945ca0e46158f5a3b7ea to your computer and use it in GitHub Desktop.
native-mixed-click.js
// 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