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

Add Widget bug #20

Closed
ashishpadave opened this issue Dec 4, 2014 · 7 comments
Closed

Add Widget bug #20

ashishpadave opened this issue Dec 4, 2014 · 7 comments
Milestone

Comments

@ashishpadave
Copy link

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

@troolee
Copy link
Member

troolee commented Dec 4, 2014

Can you give a sample?

@ashishpadave
Copy link
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.

@ashishpadave
Copy link
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.

@troolee troolee added this to the 0.2.1 milestone Dec 4, 2014
@troolee
Copy link
Member

troolee commented Dec 4, 2014

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.

@ashishpadave
Copy link
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.

@troolee
Copy link
Member

troolee commented Dec 6, 2014

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.

@troolee troolee closed this as completed Dec 6, 2014
@ashishpadave
Copy link
Author

Thank you :)

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

No branches or pull requests

2 participants