-
Notifications
You must be signed in to change notification settings - Fork 1.2k
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Prevent widget from being dragged outside of containing div? #117
Comments
I'd like to know how to do this too! |
For a fix. You can store the positions(i.e. data-col and data-row) of all the blocks before you start dragging a block. You can do this on mousedown event. Then you can bind an event draggable.stop and check all columns if any block is out of your outter div area. You can do this by base_margin + block's height + block's top position > outer div height. If this condition is true revert back to its previous positions which u stored earlier. This is not a very good fix but still works. |
Did you come up with a fix for this? |
I did not. I ended up just using jQuerys sortable widgets to solve my problem. |
This plugin is shit... i can just find one solution which i mentioned above. |
Not the creator of the library but I created a fork and am trying to help maintain the original project since the creators have all but abandoned it. The way that gridster is currently designed does not allow to contain the grid vertically. To do that you need to use my fork here: https://github.com/dustmoo/gridster.js If you configure it like so it should do what you need:
Limiting rows only works if you disable my fork from shifting larger widgets down. |
@dustmoo Thank you ! |
@hustcer You are welcome! :) |
I'd recommending checking out Packery as well. |
Nice library! Do you think they would take over gridster development? ;-) |
@dustmoo |
Helloe @dustmoo , |
$(".gridster ul").gridster({ this not works |
@harshmsp, would you setup an example so I can debug? |
Hi all,
I'm currently trying to get Gridster to constrain itself inside of a grid. I don't want it to expand vertically outside of my div. I'm currently using dustmoo's fork of Gridster for the "shift_larger_widgets_down: false" feature. What I'm trying to do is prevent it from being dragged outside of the div, but I can't seem to get any events to stop - I've tried
..but none of these seem to stop the event from happening. Is there a way I can prevent these events from happening?
For reference, I'm trying to prevent this:
From looking like this:
The text was updated successfully, but these errors were encountered: