
基于jQuery的鼠标手势支持,由于使用了canvas所以对IE 支持不好。
$.gestures.init({active:false,color:‘#ff0000′});
$.gestures.register(‘D’, function() {
alert(‘down !’);
});
// a more complex gesture : Down, Left, Up, Right
$.gestures.register(‘DLUR’, function() {
alert(‘this is a rectangle, no ?’);
});
// you can log unknown gestures :
$.gestures.error(function(gesture) {
alert(“oops, I don’t understand what \”“+gesture+“\” means”);
});
// useful keyboard tricks :
$(window).keydown(function(e) {
if ($.gestures.active() && e.which==27) {
// disable capture when user presses ESC
$.gestures.disable();
} else if (!$.gestures.active() && e.which==17) {
// enable capture when CTRL is pressed
$.gestures.enable();
}
});
$(window).keyup(function(e) {
// disable capture when CTRL is not pressed
if ($.gestures.active() && e.which==17) {
$.gestures.disable();
}
});
从上面的代码中可以看出,一开始初始化gestures,然后通过register注册鼠标手势,后面几个keyup通过判断是否按下CTRL或ESC启用或禁用全局鼠标手势。
Link: jQuery Gestures
Demo: jQuery-gestures- Image gallery
Download: jquery.gestures.js
Related posts:
- jQuery tools jQuery Tools is a collection of the most important user-interface...
Related posts brought to you by Yet Another Related Posts Plugin.


January 5th, 2009 at 4:40 pm
链接加起来,你娃现在哪里混~
January 5th, 2009 at 5:24 pm
还不是在那地方混,有啥好地方介绍介绍撒