相关疑难解决方法(0)

jQuery使用CSS转换比例拖动/调整大小

我正在应用CSS转换(以及特定于浏览器的-webkit,-o等):

transform:matrix(0.5,0,0,0.5,0,0);

到div然后使用jQuery的draggable()和resizable()插件对所述div的孩子.

我遇到的问题是,在拖动或调整子元素大小时,jQuery所做的更改与鼠标"同步"的因子等于应用的比例.

我在stackoverflow上找到了一个解决方案(虽然我愚蠢地没有将它加入书签但现在无法找到它......)建议修补插件,并且它运行得非常好.它沿着这条线走:

function monkeyPatch_mouseStart() {
  // don't really need this, but in case I did, I could store it and chain
  // var oldFn = $.ui.draggable.prototype._mouseStart ;
  $.ui.draggable.prototype._mouseStart = function(event) {

    var o = this.options;

    //Create and append the visible helper
    this.helper = this._createHelper(event);

    //Cache the helper size
    this._cacheHelperProportions();

    //If ddmanager is used for droppables, set the global draggable
    if($.ui.ddmanager)
      $.ui.ddmanager.current = this;

    /*
     * - Position generation -
     * This block generates everything position related - …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery jquery-ui css-transforms

48
推荐指数
1
解决办法
3万
查看次数

标签 统计

css ×1

css-transforms ×1

javascript ×1

jquery ×1

jquery-ui ×1