Jquery Draggable AND Resizable

前端 未结 6 526
终归单人心
终归单人心 2020-12-01 08:03
function makeResourceDrag(arrIndexID) {

    $(\'#imgA\' + arrIndexID).resizable();

    $(\'#imgA\' + arrIndexID).draggable({
        start: function(event, ui) {
          


        
6条回答
  •  生来不讨喜
    2020-12-01 08:35

    The code responsible for this was a workaround for something else: ​Github link which point to Bug 1749.

    // bugfix for http://dev.jquery.com/ticket/1749
    if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
        el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
    }
    

    The fix itself exists since the beginning of time: ​Github Bug Fixed link for Jquery

    // bugfix #1749
    if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
    
        // sOffset decides if document scrollOffset will be added to the top/left of the resizable element
        var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position'));
        var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0;
    
        el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) });
    }
    

    And was effectively just updated once, 7 years ago: ​Updated Link

    // bugfix #1749
            // bugfix for http://dev.jquery.com/ticket/1749
            if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
                // sOffset decides if document scrollOffset will be added to the top/left of the resizable element
                var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position'));
                var dscrollt = sOffset ? this.documentScroll.top : 0, dscrolll = sOffset ? this.documentScroll.left : 0;
    
                el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) });
                el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
            }
    

    Reference : jquery link

提交回复
热议问题