ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.04k stars 1.2k forks source link

resize option not work #596

Open 100cm opened 6 years ago

100cm commented 6 years ago
ERROR TypeError: Cannot read property 'width' of undefined
    at d.h.resizable (scripts.bundle.js:15077)
    at d.h.init (scripts.bundle.js:15077)
    at new d (scripts.bundle.js:15077)

when i init the gridster

  $(".gridster ul").gridster({
      widget_margins: [10, 10],
      widget_base_dimensions: [140, 140],
      helper: 'clone',
      resize: {
        enabled: true,
      }
bipin244 commented 6 years ago

I face the same issue can anyone get any solutions?

100cm commented 6 years ago

@bipin244 i fixed this by adding safe navigator to source code.

  fn.resizable = function () {
    this.resize_api = this.$el.gridDraggable({
      items: '.' + this.options.resize.handle_class,
      offset_left: this.options.widget_margins[0],
      container_width: this.container_width,
      move_element: false,
      resize: true,
      limit: {
      //here
        width: this.options.max_cols !== Infinity || (this.limit || {}).width,
        height: this.options.max_rows !== Infinity || (this.limit || {}).height
      },
      scroll_container: this.options.scroll_container,
      start: $.proxy(this.on_start_resize, this),
      stop: $.proxy(function (event, ui) {
        delay($.proxy(function () {
          this.on_stop_resize(event, ui);
        }, this), 120);
      }, this),
      drag: throttle($.proxy(this.on_resize, this), 60)
    });

    return this;
  };

kevinch1 commented 6 years ago

I see this issue was reported on January the 2, and @icepoint0 provided a solution the 12, I've just downloaded the library and encountered the same problem, tried his fix and it works, if not already, this should be proposed in a pull request (I do not see it in current pull requests).

sacsooo commented 5 years ago

Hi guys! I'm facing the same issue, can you especif where did you added theses line?

Thank you!

robswc commented 5 years ago

Hi guys! I'm facing the same issue, can you especif where did you added theses line?

Thank you!

Did you figure it out? Goes in the gridster.js file 👍