2011-04-01 75 views

回答

4

鼠标小部件是一种内部插件,似乎大部分(或仅)用于低级别的拖放处理。

我只是写了一篇博客文章用它来推出自己的拖放和拖放(而不是使用可拖动):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

新的鼠标插件文件使得jQuery UI的平均 小14%的鼠标插件是不是新的,但这种释放它移动到自己的文件,jquery.ui.mouse.js,它在里面前jQuery UI Core。这意味着不依赖于鼠标插件但之前包含jQuery UI Core的jQuery UI插件包含较少的未使用代码,平均整体文件大小提高了14%。这只是一个平均值。一些改进将高达36%。

jQuery blog 2010年3月

在你的jQuery库(就像this from google),你可以找到它作为* jQuery UI的鼠标在jQuery UI Mouse in the JQs website 1.8.11和更多信息。

+0

是有任何网站了解有关鼠标小部件的使用情况。 :(??? – Santhanam 2011-04-01 13:21:24

+2

它没有任何有效的信息.... :( – Santhanam 2011-04-01 13:23:12

相关问题