有谁知道jQuery UI鼠标小部件?

我已经开始使用jQuery UI了.

我想了解更多有关jQuery UI鼠标小部件的信息.我正在试图找出它的文档,但它不可用.任何人都知道资源的可用位置?

最佳答案
Mouse小部件是一个内部插件,似乎主要(或仅)用于低级拖放处理.

我刚刚写了一篇关于使用它来推送你自己的拖放(而不是使用Draggable)的博文:http://www.solitr.com/blog/2012/05/roll-your-own-drag-and-drop-handling-with-jquery-ui/

它的要点是,你可以将它子类化,如下:

$.widget('ui.custommouse',$.ui.mouse,{
  options: {
    mouseStart: function(e) {},mouseDrag: function(e) {},mouseStop: function(e) {},mouseCapture: function(e) { return true; }
  },// Forward events to custom handlers
  _mouseStart: function(e) { return this.options.mouseStart(e); },_mouseDrag: function(e) { return this.options.mouseDrag(e); },_mouseStop: function(e) { return this.options.mouseStop(e); },_mouseCapture: function(e) { return this.options.mouseCapture(e); }
  // Bookkeeping,inspired by Draggable
  widgetEventPrefix: 'custommouse',_init: function() {
    return this._mouseInit();
  },_create: function() {
    return this.element.addClass('ui-custommouse');
  },_destroy: function() {
    this._mouseDestroy();
    return this.element.removeClass('ui-custommouse');
  },});

然后实例化你刚定义的custommouse插件,并传递你自己的插件
事件处理程序作为选项:

$('#containerElement').custommouse({
  mouseStart: function(e) { ... },mouseDrag: function(e) { ... },mouseStop: function(e) { ... }
});

相关文章

1.第一步 设置响应头 header('Access-Control-Allow...
$.inArray()方法介绍 $.inArray()函数用于在数组中搜索指定的...
jquery.serializejson.min.js的妙用 关于这个jquery.seriali...
JS 将form表单数据快速转化为object对象(json对象) jaymou...
jQuery插件之jquery.spinner数字智能增减插件 参考地址:http...