Skip to content
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

Add a way to toggle scrollToBottom so you can start scroll from the top as well and continue reading #915

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion doc/SDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function main() {
navigation,
});
await vm.load();
const view = new TimelineView(vm.timelineViewModel, viewClassForTile);
const view = new TimelineView(vm.timelineViewModel, { viewClassForTile });
app.appendChild(view.mount());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/web/ui/session/room/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class RoomView extends TemplateView {
)]),
t.mapView(vm => vm.timelineViewModel, timelineViewModel => {
return timelineViewModel ?
new TimelineView(timelineViewModel, this._viewClassForTile) :
new TimelineView(timelineViewModel, { viewClassForTile: this._viewClassForTile }) :
new TimelineLoadingView(vm); // vm is just needed for i18n
}),
t.mapView(vm => vm.composerViewModel,
Expand Down
13 changes: 12 additions & 1 deletion src/platform/web/ui/session/room/TimelineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,27 @@ function findFirstNodeIndexAtOrBelow(tiles: HTMLElement, top: number, startIndex
return 0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing (alternative incoming)

interface TimelineViewOpts {
viewClassForTile: ViewClassForEntryFn
stickToBottom: boolean
}
export class TimelineView extends TemplateView<TimelineViewModel> {

private anchoredNode?: HTMLElement;
private anchoredBottom: number = 0;
private stickToBottom: boolean = true;
private tilesView?: TilesListView;
private resizeObserver?: ResizeObserver;
private viewClassForTile: ViewClassForEntryFn;

constructor(vm: TimelineViewModel, private readonly viewClassForTile: ViewClassForEntryFn) {
constructor(vm: TimelineViewModel, {
viewClassForTile,
stickToBottom = true
}: TimelineViewOpts) {
Comment on lines +73 to +76
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made this an options object because I forsee more options here (see future notes in PR description)

super(vm);

this.viewClassForTile = viewClassForTile;
this.stickToBottom = stickToBottom;
}

render(t: Builder<TimelineViewModel>, vm: TimelineViewModel) {
Expand Down