imgareaselect icon indicating copy to clipboard operation
imgareaselect copied to clipboard

Wrong position in bootstrap modal

Open paradisehuman opened this issue 11 years ago • 2 comments

Hi. I set parent in initializing imgAreaSelect to prevent scroll moving area :

thumb.imgAreaSelect({ handles: true, aspectRatio: '1:1', fadeSpeed: 300, parent: "#thumbBox" }) and this is my html :

paradisehuman avatar Dec 02 '13 06:12 paradisehuman

I solved this My self... Refer to this link : Fix #39

We must remove these lines from code :

/* Also check if any of the ancestor elements has fixed position */ if ($p.css('position') == 'fixed') position = 'fixed'; And we must position relative the parent box that we initialized ourselves( parent: "#thumbBox").

paradisehuman avatar Dec 02 '13 18:12 paradisehuman

FWIW, I needed to make an additional change (in addition to removing position="fixed") for this to work in my bootstrap v3.0 modal.

If I passed in the parent then the offsets were being based off the body rather than off the modal container. Passing in the img.offsetParent as the parent element almost fixed it since the offsets were then correct, but the elements were then appended at the wrong place in the DOM.

The way I eventually got it working was passing in img.parent() as my parent, but then in the adjust() function I needed to use the img's offsetParent rather than parent to get the correct offsets. My diff looks like:

+++ b/EatWith/static/lib/jquery.imgareaselect/jquery.imgareaselect-0.9.10.js
@@ -146,9 +146,10 @@ $.imgAreaSelect = function (img, options) {
             imgOfs.left += max(document.body.scrollLeft, docElem.scrollLeft);
         }

-        parOfs = /absolute|relative/.test($parent.css('position')) ?
-            { left: round($parent.offset().left) - $parent.scrollLeft(),
-                top: round($parent.offset().top) - $parent.scrollTop() } :
+        var offsetParent = $parent.offsetParent();
+        parOfs = /absolute|relative/.test(offsetParent.css('position')) ?
+            { left: round(offsetParent.offset().left) - offsetParent.scrollLeft(),
+                top: round(offsetParent.offset().top) - offsetParent.scrollTop() } :

acechase avatar Nov 13 '14 02:11 acechase