gridster.js icon indicating copy to clipboard operation
gridster.js copied to clipboard

reinitialize grid for dynamical widgets.

Open FRickReich opened this issue 12 years ago • 15 comments

so i found out what i wanted to tell you in the other post, i added a

this.init();

at row 1013 (in my copy of the file) just before

return $widget;

it reinitializes the grid after repositioning a dynamically added widget, so it wont crash the grid after certain movements.

FRickReich avatar Feb 28 '13 23:02 FRickReich

Alright, go ahead and try it without the change. I updated the code that added dynamic widgets because of all sorts of data bugs.

On my production application, I don't have any problem with positioning dynamically added widgets.

Let me double check though, I may have made a new function.

dustmoo avatar Feb 28 '13 23:02 dustmoo

Looks like I updated add_widget.. see if it works for you. If not I'll update the code. :)

dustmoo avatar Feb 28 '13 23:02 dustmoo

nope, doesnt work, additionally it seems that when i have a widget and there is a widget below it, and i drag it, and move the mouse downwards it will push the widget below down and down and down everytime it collides with the widget below, and when it hits the browser bottom it crashes and puts all widgets to row 1. wow what the hell did i screw up here :/

FRickReich avatar Feb 28 '13 23:02 FRickReich

Nothing that can't be fixed. :)

Try adding the config option that prevents larger widgets from moving down.

It's in the readme.

On Thursday, February 28, 2013, Frederik Reich wrote:

nope, doesnt work, additionally it seems that when i have a widget and there is a widget below it, and i drag it, and move the mouse downwards it will push the widget below down and down and down everytime it collides with the widget below, and when it hits the browser bottom it crashes and puts all widgets to row 1. wow what the hell did i screw up here :/

— Reply to this email directly or view it on GitHubhttps://github.com/dustmoo/gridster.js/issues/1#issuecomment-14264952 .

dustmoo avatar Feb 28 '13 23:02 dustmoo

This is the option you need:

$.gridster({
    shift_larger_widgets_down: false
});

I'll add the reinit script. I see the problem with the widgets not shifting up. (without the above option) but I need to look into it further.

The above option basically makes it so that larger widgets will swap with smaller widgets, but not the other way around. It works better with the swapping system.

dustmoo avatar Feb 28 '13 23:02 dustmoo

Also, my lines are different, what function was that amended too?

dustmoo avatar Feb 28 '13 23:02 dustmoo

here play around a bit with my test, and see if it works to your liking. https://dl.dropbox.com/u/2863238/gridster/gridster_dustmoo.html

FRickReich avatar Feb 28 '13 23:02 FRickReich

Right, I see the problem.

If you wouldn't mind sending me a link to a zip of that demo, I'll play around and see if I can fix the behavior of the script.

Also, try it with the option above.

Thanks.

dustmoo avatar Mar 01 '13 00:03 dustmoo

i added the option you mentioned above, it killed the ability to move stuff at all haha :8ball:
here's the zip, dont wonder about the css tho, it contains stuff from the gridster homepage, i didnt really work around yet because i was more or less just testing out so far.

https://dl.dropbox.com/u/2863238/gridster/gridster_dustmoo.zip

btw i more or less accidently added you on skype.

FRickReich avatar Mar 01 '13 00:03 FRickReich

Great! I am near Seattle and gotta end for the day. And am pretty tied up throughout the weekend.

I'll go ahead and spend some time on this on Monday and see what I can do. This use case gives me some ideas on how to update the library. But alas, it isn't ready yet.

Based on what I figure out Monday we can schedule a Skype for sure. Germany right?

dustmoo avatar Mar 01 '13 01:03 dustmoo

sure we can, yeah i am from germany and the time difference is a good thing because "i dont have time on monday" only counts for my timeframe and work hours ;)

FRickReich avatar Mar 01 '13 10:03 FRickReich

Fixed your whitespace issue. It should work better for your project now. :)

dustmoo avatar Apr 03 '13 16:04 dustmoo

I had some similar issues with resizing widgets and fixed them without having to do .init() which is very slow. This relates to ducksboard version, but hopefully can be fixed in the dustmoo version as well.

inside of fn.add_faux_cols , find the following line: var max_cols = actual_cols + (cols || 1);

add this line directly BELOW it: if (max_cols > this.max_cols) { return this; }

inside of fn.generate_grid_and_stylesheet , find the following line: this.cols = Math.max(min_cols, cols, this.options.min_cols);

add this line directly BELOW it: this.max_cols = this.cols;

inside of fn.resize_widget , find the following line: return $widget;

add this line directly ABOVE it: this.set_dom_grid_height();

This combination seems to have fixed my issue and should resolve this issue as well.

bompus avatar May 04 '13 07:05 bompus

Thanks for your contribution, I'll incorporate then ASAP.

On Sat, May 4, 2013 at 12:06 AM, bompus [email protected] wrote:

I had some similar issues with resizing widgets and fixed them without having to do .init() which is very slow. This relates to ducksboard version, but hopefully can be fixed in the dustmoo version as well. inside of fn.add_faux_cols , find the following line: var max_cols = actual_cols + (cols || 1); add this line directly BELOW it: if (max_cols > this.max_cols) { return this; } inside of fn.generate_grid_and_stylesheet , find the following line: this.cols = Math.max(min_cols, cols, this.options.min_cols); add this line directly BELOW it: this.max_cols = this.cols; inside of fn.resize_widget , find the following line: return $widget; add this line directly ABOVE it: this.set_dom_grid_height();

This combination seems to have fixed my issue and should resolve this issue as well.

Reply to this email directly or view it on GitHub: https://github.com/dustmoo/gridster.js/issues/1#issuecomment-17429055

dustmoo avatar May 06 '13 02:05 dustmoo

any update for this issue?

xycloud avatar May 08 '17 16:05 xycloud