Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>By modifying the code jQuery uses to implement the <code>alsoResize</code> option, we can make our own <code>alsoResizeReverse</code> option. Then we can simply use this as follows:</p> <pre><code>$("#resizable").resizable({ alsoResizeReverse: ".myframe" }); </code></pre> <p><em>The structure of the original <code>alsoResize</code> option has been changed over the various versions of jQuery UI and my original code does not work in the newer versions. I'll give the code for adding this functionality in version 1.8.1 and 1.11.4.</em></p> <p>Only a few things had to be changed, such as the obvious renaming <code>alsoResize</code> to <code>alsoResizeReverse</code> and subtracting the <code>delta</code> instead of adding it (what makes the resize reversed). The original <code>alsoResize</code> code starts on line 2200 of <a href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.js" rel="noreferrer">version 1.8.1</a> of jQuery UI and line 7922 of <a href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js" rel="noreferrer">version 1.11.4</a>. You can see the few changes needed <a href="https://github.com/siniec/jquery-ui-alsoresize-reverse/commit/81cc67a8ee8fd212fc3cc6dcbdf3c22c943e0450" rel="noreferrer">here</a>.</p> <p>To add the <code>alsoResizeReverse</code> functionality, add this to your javascript (This should be put outside of document.ready()):</p> <p>For newer versions of jQuery UI (example is based on v1.11.4):</p> <pre><code>$.ui.plugin.add("resizable", "alsoResizeReverse", { start: function() { var that = $(this).resizable( "instance" ), o = that.options; $(o.alsoResizeReverse).each(function() { var el = $(this); el.data("ui-resizable-alsoresizeReverse", { width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10) }); }); }, resize: function(event, ui) { var that = $(this).resizable( "instance" ), o = that.options, os = that.originalSize, op = that.originalPosition, delta = { height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0, top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0 }; $(o.alsoResizeReverse).each(function() { var el = $(this), start = $(this).data("ui-resizable-alsoresize-reverse"), style = {}, css = el.parents(ui.originalElement[0]).length ? [ "width", "height" ] : [ "width", "height", "top", "left" ]; $.each(css, function(i, prop) { var sum = (start[prop] || 0) - (delta[prop] || 0); if (sum &amp;&amp; sum &gt;= 0) { style[prop] = sum || null; } }); el.css(style); }); }, stop: function() { $(this).removeData("resizable-alsoresize-reverse"); } }); </code></pre> <p>For older version (based on v1.8.1 -- my original answer):</p> <pre><code>$.ui.plugin.add("resizable", "alsoResizeReverse", { start: function(event, ui) { var self = $(this).data("resizable"), o = self.options; var _store = function(exp) { $(exp).each(function() { $(this).data("resizable-alsoresize-reverse", { width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10), left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) }); }); }; if (typeof(o.alsoResizeReverse) == 'object' &amp;&amp; !o.alsoResizeReverse.parentNode) { if (o.alsoResizeReverse.length) { o.alsoResize = o.alsoResizeReverse[0]; _store(o.alsoResizeReverse); } else { $.each(o.alsoResizeReverse, function(exp, c) { _store(exp); }); } }else{ _store(o.alsoResizeReverse); } }, resize: function(event, ui){ var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition; var delta = { height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 }, _alsoResizeReverse = function(exp, c) { $(exp).each(function() { var el = $(this), start = $(this).data("resizable-alsoresize-reverse"), style = {}, css = c &amp;&amp; c.length ? c : ['width', 'height', 'top', 'left']; $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { var sum = (start[prop]||0) - (delta[prop]||0); // subtracting instead of adding if (sum &amp;&amp; sum &gt;= 0) style[prop] = sum || null; }); //Opera fixing relative position if (/relative/.test(el.css('position')) &amp;&amp; $.browser.opera) { self._revertToRelativePosition = true; el.css({ position: 'absolute', top: 'auto', left: 'auto' }); } el.css(style); }); }; if (typeof(o.alsoResizeReverse) == 'object' &amp;&amp; !o.alsoResizeReverse.nodeType) { $.each(o.alsoResizeReverse, function(exp, c) { _alsoResizeReverse(exp, c); }); }else{ _alsoResizeReverse(o.alsoResizeReverse); } }, stop: function(event, ui){ var self = $(this).data("resizable"); //Opera fixing relative position if (self._revertToRelativePosition &amp;&amp; $.browser.opera) { self._revertToRelativePosition = false; el.css({ position: 'relative' }); } $(this).removeData("resizable-alsoresize-reverse"); } }); </code></pre> <p>Here's a demo: <a href="http://jsfiddle.net/WpgzZ/" rel="noreferrer">http://jsfiddle.net/WpgzZ/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload