Skip to content

Add Widget bug #20

Closed
Closed

Description

@ashishpadave

While adding a widget, the constraints of the grid (width and height) are not respected.

Activity

  1. troolee commented on Dec 4, 2014

    @troolee
    Member

    Can you give a sample?

  2. ashishpadave commented on Dec 4, 2014

    @ashishpadave
    Author

    I have used the demo html and added the following script and a button.

    <input id="add_widget" type="button" value="Add Widget" style="color:#000"/>
    <script type="text/javascript">
                $(function() {
                    $('.grid-stack').gridstack({
                        width: 12,
                        height:10,
                        cell_height: 50,
                        vertical_margin: 5,
                    });
                });
    
                $('#add_widget').click(function(){
                    var el = $.parseHTML("<div><div class=\"grid-stack-item-content\"/><div/>");
                    var grid = $('.grid-stack').data('gridstack');
                    grid.add_widget(el, 1, 1, 4, 1, true);
                });
    </script>

    If i keep clicking the add_widget button, the widgets continue to get added beyond the max number of rows.

  3. ashishpadave commented on Dec 4, 2014

    @ashishpadave
    Author

    http://screencast.com/t/IGZ9txKZYh

    Notice that the first item is added on the right and its bigger than the max _width defined. While the last item that is added at the bottom is also beyond the height limit.

  4. added this to the 0.2.1 milestone on Dec 4, 2014
  5. troolee commented on Dec 4, 2014

    @troolee
    Member

    Thank you for feedback.

    I will check auto positioning. Also I will add a method which will help to check if a widget could be added with respect to vertical constraint. I don't think that height property should restrict from adding.

  6. ashishpadave commented on Dec 4, 2014

    @ashishpadave
    Author

    If height is not explicitly defined then the height property should not be restrictive. But if someone has defined the height then the add_widget should definitely restrict or at least warn the user that the new widget is being added beyond the set width / height restrictions.

  7. troolee commented on Dec 6, 2014

    @troolee
    Member

    I've fixed the bug with auto-positioning. I've also added a new method will_it_fit. You have to check by yourself before add a widget. Please see the README.md.

  8. ashishpadave commented on Dec 9, 2014

    @ashishpadave
    Author

    Thank you :)

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions