Skip to content

Resizing does not work as expected #1166

Closed

Description

@pjc0247

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

Activity

  1. awjae commented on Feb 26, 2020

    @awjae
    Contributor

    Temporary Quick Solution

    Check gridstack.all.js cdn file
    https://cdn.jsdelivr.net/npm/gridstack@1.0.0/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"))

  2. adumesny commented on Feb 26, 2020

    @adumesny
    Member

    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!

  3. added a commit that references this issue on Feb 27, 2020
  4. adumesny commented on Feb 27, 2020

    @adumesny
    Member

    fixed in next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions