|
369 | 369 | this.set_dom_grid_width();
|
370 | 370 | this.set_dom_grid_height();
|
371 | 371 |
|
372 |
| - this.drag_api.set_limits(this.cols * this.min_widget_width); |
| 372 | + this.drag_api.set_limits((this.cols * this.min_widget_width) + ((this.cols + 1) * this.options.widget_margins[0])); |
373 | 373 |
|
374 | 374 | return $w.fadeIn();
|
375 | 375 | };
|
|
1233 | 1233 | if (prcol >= this.cols - 1 && this.options.max_cols >= this.cols + 1) {
|
1234 | 1234 | this.add_faux_cols(1);
|
1235 | 1235 | this.set_dom_grid_width(this.cols + 1);
|
1236 |
| - this.drag_api.set_limits(this.container_width); |
| 1236 | + this.drag_api.set_limits((this.cols * this.min_widget_width) + ((this.cols + 1) * this.options.widget_margins[0])); |
1237 | 1237 | }
|
1238 | 1238 |
|
1239 | 1239 | this.collision_api.set_colliders(this.faux_grid);
|
|
1324 | 1324 | this.set_dom_grid_width();
|
1325 | 1325 |
|
1326 | 1326 | if (this.options.autogrow_cols) {
|
1327 |
| - this.drag_api.set_limits(this.cols * this.min_widget_width); |
| 1327 | + this.drag_api.set_limits((this.cols * this.min_widget_width) + ((this.cols + 1) * this.options.widget_margins[0])); |
1328 | 1328 | }
|
1329 | 1329 | };
|
1330 | 1330 |
|
|
2914 | 2914 | };
|
2915 | 2915 |
|
2916 | 2916 | /**
|
2917 |
| - * |
| 2917 | + * Generates the width of the grid columns based on the width of the window. |
2918 | 2918 | * @returns {number}
|
2919 | 2919 | */
|
2920 | 2920 | fn.get_responsive_col_width = function() {
|
2921 | 2921 | var cols = this.cols || this.options.max_cols;
|
2922 | 2922 | return (this.$el.width() - ((cols + 1) * this.options.widget_margins[0])) / cols;
|
2923 | 2923 | };
|
2924 | 2924 |
|
| 2925 | + /** |
| 2926 | + * Changes the minimum width of a widget based on the width of the window and the number of cols that can |
| 2927 | + * fit in it. |
| 2928 | + * @returns {Gridster} |
| 2929 | + */ |
2925 | 2930 | fn.resize_responsive_layout = function() {
|
2926 | 2931 | this.min_widget_width = this.get_responsive_col_width();
|
2927 | 2932 | this.generate_grid_and_stylesheet();
|
2928 | 2933 | this.update_widgets_dimensions();
|
2929 |
| - this.drag_api.set_limits((this.cols * this.min_widget_width) + ((this.cols) * this.options.widget_margins[0])); |
| 2934 | + this.drag_api.set_limits((this.cols * this.min_widget_width) + ((this.cols + 1) * this.options.widget_margins[0])); |
| 2935 | + return this; |
2930 | 2936 | };
|
2931 | 2937 |
|
| 2938 | + /** |
| 2939 | + * Switches between collapsed widgets the span the full width when the responsive_breakpoint is triggered. |
| 2940 | + * @param collapse |
| 2941 | + * @param opts |
| 2942 | + * @returns {Gridster} |
| 2943 | + */ |
2932 | 2944 | fn.toggle_collapsed_grid = function(collapse, opts) {
|
2933 | 2945 | if(collapse) {
|
2934 | 2946 | this.$widgets.css({
|
|
2939 | 2951 |
|
2940 | 2952 | this.$el.addClass('collapsed');
|
2941 | 2953 |
|
2942 |
| - if(this.options.resize.enabled && this.resize_api) { |
| 2954 | + if(this.resize_api) { |
2943 | 2955 | this.disable_resize();
|
2944 | 2956 | }
|
2945 | 2957 |
|
|
2953 | 2965 | 'min-height': 'auto'
|
2954 | 2966 | });
|
2955 | 2967 | this.$el.removeClass('collapsed');
|
2956 |
| - if(this.options.resize.enabled && this.resize_api) { |
| 2968 | + if(this.resize_api) { |
2957 | 2969 | this.enable_resize();
|
2958 | 2970 | }
|
2959 | 2971 |
|
2960 | 2972 | if(this.drag_api) {
|
2961 | 2973 | this.enable();
|
2962 | 2974 | }
|
2963 | 2975 | }
|
2964 |
| - } |
| 2976 | + return this; |
| 2977 | + }; |
2965 | 2978 |
|
2966 | 2979 | /**
|
2967 |
| - * It generates the neccessary styles to position the widgets. |
| 2980 | + * It generates the necessary styles to position the widgets. |
2968 | 2981 | *
|
2969 | 2982 | * @method generate_stylesheet
|
2970 | 2983 | * @param {Number} rows Number of columns.
|
|
0 commit comments