Skip to content

Scroll to the start of the given day #73

@MadLittleMods

Description

@MadLittleMods

Following up with the UX problems mentioned in #71, we should page-load the scroll position to the start of the day so the date header is just in view at the top.

Here is a mock-up using Element:

Mock-up using Element

Currently, the page is always scrolled to the very bottom.

Blockers

UX considerations

  1. What happens when there are no messages for the given day?
    • Any empty placeholder shown?
    • How does scroll work?
  2. What happens when there isn't enough messages to fill up the viewport?

Dev notes

It would be nice to have this functionality built-in to Hydrogen. Although permalinks to jump to a specific message aren't supported in Hydrogen and even if they did, they probably want to scroll the event to the middle of the view instead of at the top like we would.

Scratch code
scrollToEventId(rootElement, eventId, scrollIntoViewOptions) {
  const scrollRoot = rootElement.querySelector('.Timeline_scroller');

  const elementToScrollTo = scrollRoot.querySelector(
    `:scope > ul > [data-event-id="${eventId}"]`
  );
  console.log('elementToScrollTo', elementToScrollTo);
  elementToScrollTo?.scrollIntoView(
    scrollIntoViewOptions || {
      block: 'start',
      inline: 'nearest',
    }
  );
}

requestAnimationFrame(() => {
  this.scrollToEventId(rootElement, '$MRQON0wYqnapzYsa9XmAaxgB5qxvhLCC4Gd0ZuSSdpI');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-archive-room-viewThe view to look at a room day by day in the archiveT-EnhancementNew feature or requestZ-Confidence-LowLow confidence in the enhancement or suggestion based on known factors, or as described.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions