angular-gridster2 icon indicating copy to clipboard operation
angular-gridster2 copied to clipboard

api.resize() method -> checkIfToResize(): why not resize if (verticalScrollPresent)?

Open jayoma opened this issue 9 years ago • 3 comments

On line 145 of gridster.component.ts (within the checkIfToResize() method):

checkIfToResize(): boolean {
    const clientWidth = this.el.clientWidth;
    const offsetWidth = this.el.offsetWidth;
    const scrollWidth = this.el.scrollWidth;
    const clientHeight = this.el.clientHeight;
    const offsetHeight = this.el.offsetHeight;
    const scrollHeight = this.el.scrollHeight;
    const verticalScrollPresent = clientWidth < offsetWidth && scrollHeight > offsetHeight
      && scrollHeight - offsetHeight < offsetWidth - clientWidth;
    const horizontalScrollPresent = clientHeight < offsetHeight
      && scrollWidth > offsetWidth && scrollWidth - offsetWidth < offsetHeight - clientHeight;
    if (verticalScrollPresent) {
      return false;
    }
    return !horizontalScrollPresent;
  }

Can you help me understand why we wouldn't want the grid to resize, in the case that the vertical scrollbar is present? This doesn't seem like a safe assumption to me, and I'm seeing examples of the onResize() method not getting called in cases where it should.

I guess my thought is that if I explicitly call the api's resize() method, it should always resize. Because I told it to. I guess for now, I'm going to have to create a template variable/ViewChild reference, and explicitly call the GridsterComponent's onResize() method.

jayoma avatar Sep 26 '17 22:09 jayoma

Hi @jasonhendee ,

The checks there are made so it will not enter in a infinite cycle because the method is called again from calculateLayout, when the size of the screen and size of the grid is really close to have or not to have a scrollbar.

Yes on the api resize() call should make it to always resize. Will try to add it as soon as possible.

Thanks,

tiberiuzuld avatar Sep 27 '17 07:09 tiberiuzuld

Thank you! I'll keep an eye out for that enhancement, but the ViewChild reference will work for now.

jayoma avatar Sep 27 '17 15:09 jayoma

Hi @jasonhendee ,

Fixed in 3.13.0

Thanks,

tiberiuzuld avatar Oct 07 '17 10:10 tiberiuzuld