Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested grid looses verticalMargin setting when parent grid item moved (inherits parent setting) #726

Closed
kool-kat opened this issue Jul 25, 2017 · 3 comments
Labels

Comments

@kool-kat
Copy link

kool-kat commented Jul 25, 2017

I have a nested grid with its own verticalMargin setting, which differs to the parent (wrapper) grid.

Moving a parent grid widget results in the nested grid being redrawn with the parent margin setting not its own.

Movie showing this is attached.
nestedloosemargin.zip

My grid code:

<!--WRAPPER--><div class="myGrid" style="background: #2c3e50;">
<div class="grid-stack grid-stack-8" data-gs-animate="yes"><!--START GRID-->
<div class="grid-stack-item" data-gs-x="0" data-gs-y="0" data-gs-width="3" data-gs-height="3"><div class="grid-stack-item-content clr1">1<br/><p>Shoot me an email.</p></div></div>
<div class="grid-stack-item" data-gs-x="3" data-gs-y="0" data-gs-width="2" data-gs-height="3"><div class="grid-stack-item-content clr2">2<br><strong>hello</strong><p>This is a no-brainer.</p></div></div>
<div class="grid-stack-item" data-gs-x="5" data-gs-y="0" data-gs-width="3" data-gs-height="3"><div class="grid-stack-item-content clr3">3<br>hello</div></div>
<div class="grid-stack-item" data-gs-x="0" data-gs-y="3" data-gs-width="2" data-gs-height="3"><div class="grid-stack-item-content clr2">4<br>world</div></div>
<div class="grid-stack-item" data-gs-x="2" data-gs-y="3" data-gs-width="4" data-gs-height="6"><div class="grid-stack-item-content clr3"><!-- HERE--><div class="grid-inner grid-stack-2" data-gs-animate="yes"><!--START INNER GRID-->
<div class="grid-inner-item grid-stack-item" data-gs-x="0" data-gs-y="0" data-gs-width="1" data-gs-height="3"><div class="grid-stack-item-content clr7">Inner1</div></div>
<div class="grid-inner-item grid-stack-item" data-gs-x="1" data-gs-y="0" data-gs-width="1" data-gs-height="3"><div class="grid-stack-item-content clr6">Inner2</div></div>
<div class="grid-inner-item grid-stack-item" data-gs-x="0" data-gs-y="3" data-gs-width="1" data-gs-height="3"><div class="grid-stack-item-content clr6">Inner3</div></div>
<div class="grid-inner-item grid-stack-item" data-gs-x="1" data-gs-y="3" data-gs-width="1" data-gs-height="3"><div class="grid-stack-item-content clr7">Inner4</div></div>
<!-- END INNER GRID --></div></div></div>
<div class="grid-stack-item" data-gs-x="6" data-gs-y="3" data-gs-width="2" data-gs-height="3"><div class="grid-stack-item-content clr9">5</div></div>
<div class="grid-stack-item" data-gs-x="0" data-gs-y="6" data-gs-width="2" data-gs-height="3"><div class="grid-stack-item-content clr0">6</div></div>
<div class="grid-stack-item" data-gs-x="6" data-gs-y="6" data-gs-width="2" data-gs-height="3"><div class="grid-stack-item-content clr8">7</div></div><!-- END GRID --></div>
<!--end wrapper--></div>

My function and options:

  $(function () {
        var options = {
             width: 8,
             verticalMargin: 3,
             cellHeight:'3.5em',
             resizable: {
                   handles: 'e, se, s, sw, w'
                              }
          };
         $('.grid-stack').gridstack(options);

var nestedoptions = {
             width:2,
             verticalMargin: 0,
             cellHeight:'3.5em',
             resizable: {
                   handles: 'e, se, s, sw, w'
                              }
          };
         $('.grid-inner').gridstack(nestedoptions);
   });
@radiolips
Copy link
Member

@kool-kat I believe there's an existing ticket that mentions this. If I can find the ticket, I'll mention the link here and close this ticket. If not, I'll keep this open. Thanks again for logging all of these bugs - if we're unaware of the issues, we can't make the fixes.

@adumesny
Copy link
Member

I tried latest code and modified nested.html and still happens when moving, even with fix for #425 to have copy of the options per grid.

adumesny added a commit to adumesny/gridstack.js that referenced this issue Jul 7, 2020
* complete re-write how we size/position items dealing with margin
* we now have a single `margin` grid option which will set all 4 sides instead of one in code nad one in CSS
* also have `marginTop/Bottom/Left/Right` if more precise setting is required
* greatly reduced the layout code as margin are now inside the grid-item
(affects content)
* fixed code so `cellHeight: 'auto'` (now the default) will create real square cells
(used to be off due to margin)
* grid will now have consistant spacing (above/below first/last rows)
@adumesny
Copy link
Member

adumesny commented Jul 7, 2020

this will be fixed in upcoming 2.0 release - as you can see parent grid has 10px margin, nested 1px and that stays while dragging items around in parent or child.
image

adumesny added a commit that referenced this issue Jul 27, 2020
TS: #723 #726 `margin` to replace `verticalMargin`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants