Skip to content

feat: scroll timeline to current time on open#787

Open
kthurman59 wants to merge 1 commit intoivan-lednev:mainfrom
kthurman59:feature/center-needle-scroll-on-open
Open

feat: scroll timeline to current time on open#787
kthurman59 wants to merge 1 commit intoivan-lednev:mainfrom
kthurman59:feature/center-needle-scroll-on-open

Conversation

@kthurman59
Copy link
Copy Markdown

Fixes #222

This change makes the Timeline sidebar scroll to the current time when you open it, as long as the existing “Center the Pointer in the Timeline View” setting is turned on.

What it does

  • If “Center the Pointer in the Timeline View” is on and you open the Timeline for today, the view scrolls so the current time needle ends up roughly in the middle of the visible area.
  • If you open the Timeline for a date that is not today, the scroll position is left as is.
  • If the setting is off, the Timeline behaves exactly as before.
  • If the cursor is already over the timeline when it mounts, the scroll is skipped so it does not fight user initiated scrolling.

How it works

  • Reuses the existing centerNeedle setting and the isToday store.
  • Adds a helper in timeline.svelte that maps “minutes since midnight” to a vertical offset, using the existing offsetYToMinutes function together with the current zoom level and start hour.
  • Uses onMount in timeline.svelte to:
    • Find the closest .scroller element around the timeline.
    • Compute the vertical position that corresponds to the current time.
    • Scroll that container so the current time is near the center of the viewport, with clamping at the top and bottom.

Manual testing

  • Today, with several scheduled tasks and “Center the Pointer in the Timeline View” on:
    • Opening the Timeline sidebar scrolls so the current time is centered.
  • Today, with that setting off:
    • Timeline opens without any scroll adjustment.
  • On a date that is not today:
    • Timeline opens without any scroll adjustment.
  • Changing zoom level and start hour still lines up time with vertical position as expected.

Notes

  • npm test currently reports failures in the ical and integration suites on main. Those were already failing and are unrelated to this change, which only touches the timeline view.

@kthurman59
Copy link
Copy Markdown
Author

Opened a PR that scrolls the Timeline sidebar to the current time when the view opens, controlled by the existing “Center the Pointer in the Timeline View” setting. Happy to tweak the behavior if you would prefer something slightly different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have the view scroll to the current local time of the user

1 participant