Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [4.2.2-dev](#422-dev)
- [4.2.2 (2021-4-23)](#422-2021-4-23)
- [4.2.1 (2021-4-18)](#421-2021-4-18)
- [4.2.0 (2021-4-11)](#420-2021-4-11)
Expand Down Expand Up @@ -55,6 +56,11 @@ Change log
- [v0.1.0 (2014-11-18)](#v010-2014-11-18)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## 4.2.2-dev

- `Utils.getScrollParent()` -> `getScrollElement()` rename
- fix [#1745](https://github.com/gridstack/gridstack.js/issues/1745) digression on scrolling in v4.2.1. Thanks [@Manfred-on-github](https://github.com/Manfred-on-github) for fixing your prev change.

## 4.2.2 (2021-4-23)

- fix [#1684](https://github.com/gridstack/gridstack.js/issues/1684) [#1550](https://github.com/gridstack/gridstack.js/issues/1550) mac Safari H5 draggable broken in 4.0.1. Thanks [@wurambo](https://github.com/wurambo)
Expand Down
2 changes: 1 addition & 1 deletion spec/utils-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('gridstack utils', function() {
expect(el.style.position).toEqual('');

// bogus test
expect(Utils.getScrollParent(el)).not.toBe(null);
expect(Utils.getScrollElement(el)).not.toBe(null);
// bogus test
Utils.updateScrollPosition(el, {top: 20}, 10);
});
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-resizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
/** @internal */
private _resizeStart(event: MouseEvent): DDResizable {
this.originalRect = this.el.getBoundingClientRect();
this.scrollEl = Utils.getScrollParent(this.el);
this.scrollEl = Utils.getScrollElement(this.el);
this.scrollY = this.scrollEl.scrollTop;
this.startEvent = event;
this._setupHelper();
Expand Down
12 changes: 6 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,16 @@ export class Utils {
}
}

/** @internal */
static getScrollParent(el: HTMLElement): HTMLElement {
if (el === null) return document.scrollingElement as HTMLElement;
/** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */
static getScrollElement(el?: HTMLElement): HTMLElement {
if (!el) return document.scrollingElement as HTMLElement;
const style = getComputedStyle(el);
const overflowRegex = /(auto|scroll)/;

if (overflowRegex.test(style.overflow + style.overflowY)) {
return el;
} else {
return this.getScrollParent(el.parentElement);
return this.getScrollElement(el.parentElement);
}
}

Expand All @@ -317,7 +317,7 @@ export class Utils {
// to get entire widget on screen
let offsetDiffDown = rect.bottom - innerHeightOrClientHeight;
let offsetDiffUp = rect.top;
let scrollEl = this.getScrollParent(el);
let scrollEl = this.getScrollElement(el);
if (scrollEl !== null) {
let prevScroll = scrollEl.scrollTop;
if (rect.top < 0 && distance < 0) {
Expand Down Expand Up @@ -349,7 +349,7 @@ export class Utils {
* @param distance Distance from the V edges to start scrolling
*/
static updateScrollResize(event: MouseEvent, el: HTMLElement, distance: number): void {
const scrollEl = this.getScrollParent(el);
const scrollEl = this.getScrollElement(el);
const height = scrollEl.clientHeight;
const offsetTop = scrollEl.getBoundingClientRect().top;
const pointerPosY = event.clientY - offsetTop;
Expand Down