Skip to content

Use overflow-anchor as a better fix for scrolling behaviour #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2018
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
11 changes: 0 additions & 11 deletions lib/tables.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,6 @@ class Table<T> extends Object with SetStateMixin {
}

void _rebuildVirtualTable() {
// When we modify the height of the spacer above the viewport, Chrome automatically
// adjusts the scrollTop to compensate because it's trying to keep the same content
// visible to the user. However, since we're overwriting the rows contents (shifting
// the data in the rows) we want to retain the original scroll position so must stash
// it and reset it later.
final int originalScrollTop = element.scrollTop;

int firstRenderedRowInclusive = 0;
int lastRenderedRowExclusive = rows?.length ?? 0;

Expand Down Expand Up @@ -273,10 +266,6 @@ class Table<T> extends Object with SetStateMixin {
(rows.length - lastRenderedRowExclusive) * rowHeight;
_spacerAfterVisibleRows.height = '${spacerAfterHeight}px';
_tbody.element.children.add(_spacerAfterVisibleRows.element);

// Restore the scroll position the user had scrolled to since Chrome may
// have modified it after we changed the height of the "before" spacer.
element.scrollTop = originalScrollTop;
}

void _rebuildStaticTable() => _buildTableRows(
Expand Down
4 changes: 4 additions & 0 deletions web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ span.label.gc {
background-color: #424242;
}

.table-virtual {
overflow-anchor: none;
}

.table-virtual td {
max-width: 500px; /* required for text-overflow to work? */
overflow: hidden;
Expand Down