Skip to content

Commit da527cb

Browse files
authored
fix(ui5-table-growing): add rootMargin to observer (#11242)
There is an issue with subpixel rendering introducing rounding errors. The growing sample in the playground is not working with zoom lower than 100%. If the table is inside a scroll container, which is inside of an IFrame taken a fraction of the available width, rounding errors lead to the IntersectionObserver not calling the callback, as it does not detect the end-row scrolling into viewport. Added a rootMargin of 5px to try to circumvent the rounding issue by increasing the intersection area. Additionally, the root should be the scrollContainer instead of the document.
1 parent 0fb01bf commit da527cb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/main/src/TableGrowing.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
TABLE_MORE,
1515
TABLE_MORE_DESCRIPTION,
1616
} from "./generated/i18n/i18n-defaults.js";
17+
import { findVerticalScrollContainer } from "./TableUtils.js";
1718

1819
// The documentation should be similar to the Table.ts class documentation!
1920
// Please only use that style where it uses markdown and the documentation is more readable.
@@ -225,7 +226,10 @@ class TableGrowing extends UI5Element implements ITableGrowing {
225226
*/
226227
_getIntersectionObserver(): IntersectionObserver {
227228
if (!this._observer) {
228-
this._observer = new IntersectionObserver(this._onIntersection.bind(this), { root: document });
229+
this._observer = new IntersectionObserver(this._onIntersection.bind(this), {
230+
root: findVerticalScrollContainer(this._table ?? document.body),
231+
rootMargin: "5px",
232+
});
229233
}
230234
return this._observer;
231235
}

0 commit comments

Comments
 (0)