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

Resizing does not work as expected #1166

Closed
pjc0247 opened this issue Feb 26, 2020 · 3 comments · Fixed by #1169
Closed

Resizing does not work as expected #1166

pjc0247 opened this issue Feb 26, 2020 · 3 comments · Fixed by #1169
Labels

Comments

@pjc0247
Copy link

pjc0247 commented Feb 26, 2020

Subject of the issue

Resizing does not work as expected

Your environment

1.0.0 and Chrome

Steps to reproduce

https://pjc0247.github.io/bugtest/index.html

Expected behaviour

Size should follow the user input.

Actual behaviour

The object grows larger than expected.

gridstack

@awjae
Copy link
Contributor

awjae commented Feb 26, 2020

Temporary Quick Solution

Check gridstack.all.js cdn file
https://cdn.jsdelivr.net/npm/[email protected]/dist/gridstack.all.js

Edit function
function t(e, t) { f.$el.append(f.placeholder); var i = g(this); f.engine.cleanNodes(), f.engine.beginUpdate(u), d = f.cellWidth(); var n = f.cellHeight(); c = f.$el.height() / parseInt(f.$el.attr("data-gs-current-row")), f.placeholder.attr("data-gs-x", i.attr("data-gs-x")).attr("data-gs-y", i.attr("data-gs-y")).attr("data-gs-width", i.attr("data-gs-width")).attr("data-gs-height", i.attr("data-gs-height")).show(), u.el = f.placeholder.get(0), u._beforeDragX = u.x, u._beforeDragY = u.y, u._prevYPix = t.position.top; var o = u.minHeight || 1, s = f.opts.verticalMargin; f.dd.resizable(h, "option", "minWidth", d * (u.minWidth || 1)), f.dd.resizable(h, "option", "minHeight", n * o + (o - 1) * s), "resizestart" === e.type && i.find(".grid-stack-item").trigger("resizestart") }

TO

function t(e, t) { f.$el.append(f.placeholder); var i = g(this); f.engine.cleanNodes(), f.engine.beginUpdate(u), d = f.cellWidth(); var n = f.cellHeight(); c = (f.$el.height() + grid.verticalMargin()) / parseInt(f.$el.attr("data-gs-current-row")), f.placeholder.attr("data-gs-x", i.attr("data-gs-x")).attr("data-gs-y", i.attr("data-gs-y")).attr("data-gs-width", i.attr("data-gs-width")).attr("data-gs-height", i.attr("data-gs-height")).show(), u.el = f.placeholder.get(0), u._beforeDragX = u.x, u._beforeDragY = u.y, u._prevYPix = t.position.top; var o = u.minHeight || 1, s = f.opts.verticalMargin; f.dd.resizable(h, "option", "minWidth", d * (u.minWidth || 1)), f.dd.resizable(h, "option", "minHeight", n * o + (o - 1) * s), "resizestart" === e.type && i.find(".grid-stack-item").trigger("resizestart") }

It change
c = f.$el.height() / parseInt(f.$el.attr("data-gs-current-row"))
->
c = (f.$el.height() + grid.verticalMargin()) / parseInt(f.$el.attr("data-gs-current-row"))

@adumesny
Copy link
Member

adumesny commented Feb 26, 2020

by the way you can use non min files (to help debug) like the git demos (just change to URL)

<script src="../src/jquery.js"></script>
<script src="../src/gridstack.js"></script>
<script src="../src/jquery-ui.js"></script>
<script src="../src/gridstack.jQueryUI.js"></script>

You can also reproduce with our demo https://gridstackjs.com/demo/float.html
Funny thing is I recall fixing a similar issue where margin wasn't taken into account before... maybe I missed that one, or got reverted???

do you mind putting a code review fix ? that would be great!

@adumesny
Copy link
Member

fixed in next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants