Created
October 22, 2012 19:27
-
-
Save greypants/3933531 to your computer and use it in GitHub Desktop.
JS: Touch/Desktop Event Pattern
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
var supports_touch = 'ontouchend' in document; | |
var events = { | |
desktop: { | |
start : 'mousedown', | |
stop : 'mouseup', | |
move : 'mousemove', | |
leave : 'mouseleave', | |
resize : 'resize' | |
}, | |
mobile: { | |
start : 'touchstart', | |
stop : 'touchend', | |
move : 'touchmove', | |
leave : 'touchleave', | |
resize : 'orientationchange' | |
} | |
}; | |
events = supports_touch ? events.desktop : events.mobile; | |
$('.expand').bind(events.start, expandDiv); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment