Skip to content

feat(ux): add scroll-to-top and scroll-to-bottom floating buttons#562

Open
Ridanshi wants to merge 1 commit into
Shruti070107:mainfrom
Ridanshi:feat/issue-527-scroll-buttons
Open

feat(ux): add scroll-to-top and scroll-to-bottom floating buttons#562
Ridanshi wants to merge 1 commit into
Shruti070107:mainfrom
Ridanshi:feat/issue-527-scroll-buttons

Conversation

@Ridanshi

@Ridanshi Ridanshi commented Jun 1, 2026

Copy link
Copy Markdown

Closes #527

Summary

Adds two circular floating action buttons — scroll to top (↑) and scroll to bottom (↓) — that appear dynamically on long dashboard pages and disappear on short ones, with no impact on existing layout or behaviour.

Behaviour

Condition Top button Bottom button
Page not scrollable (scrollHeight ≤ clientHeight) hidden hidden
scrollTop ≤ 300 px hidden visible (if far from end)
scrollTop > 300 px visible visible (if far from end)
Within 300 px of page bottom visible hidden

Both buttons re-evaluate on every view navigation (via the regenx:viewchanged event dispatched from showView()), so switching to a short page immediately hides them.

Scrolling targets .main-area — the actual overflow-y: auto container — not window, which has overflow: hidden.

Placement & z-index

  • Position: fixed; right: 20px
  • Scroll-to-bottom: bottom: 80px — 8 px above the accessibility trigger (bottom: 20px, height: 52px)
  • Scroll-to-top: bottom: 128px — 8 px above scroll-to-bottom
  • z-index: 1500 — above modal overlay (1000), below accessibility trigger (2100) and notification drawer (9998)

Styling

Matches the existing ReGenX glassmorphism language:

  • background: var(--glass-bg) with backdrop-filter: blur(16px)
  • border: 1px solid var(--border), box-shadow: var(--shadow-lg)
  • 40 × 40 px circles on desktop; 36 × 36 px on mobile (≤ 768 px)
  • Hover state: fills to var(--green), scale(1.12), teal glow
  • Smooth opacity + transform transitions; hidden buttons have pointer-events: none

Accessibility

  • aria-label="Scroll to top" / "Scroll to bottom" on both buttons
  • focus-visible outline ring (2 px, var(--green))
  • Fully keyboard-operable

Performance

  • Single passive scroll listener on .main-area
  • RAF-throttled (requestAnimationFrame, one frame per scroll burst)
  • No layout-forcing reads outside the rAF callback

Files changed

File Change
index.html Two <button> elements before </body>
src/styles.css .scroll-nav-btn styles + mobile responsive overrides
src/app.js initScrollNav() IIFE in DOMContentLoaded; regenx:viewchanged event in showView()
scripts/test-scroll-buttons.mjs 17 test cases, 25 assertions

Test results

Results: 25 passed, 0 failed

Scenarios covered: hidden at load, visible after scroll, bottom visibility thresholds, non-scrollable pages, scroll actions, boundary conditions, view-change reset, zero-height guard, missing-element guard, mobile size constants.

…ruti070107#527)

Adds two circular floating action buttons that let users navigate long
dashboard pages without manual scrolling.

Behaviour
─────────
• Scroll-to-top (↑): visible only when .main-area.scrollTop > 300 px.
• Scroll-to-bottom (↓): visible only when the user is not already within
  300 px of the page bottom.
• Both buttons are hidden when the page is not scrollable
  (scrollHeight ≤ clientHeight).
• Scroll listener is passive and RAF-throttled (single requestAnimationFrame
  per scroll burst) — no layout thrash.
• Buttons re-evaluate on every view change via the regenx:viewchanged event
  dispatched from showView(), so short pages stay clean.

Placement & z-index
────────────────────
• Position: fixed; right: 20px — stacked above the existing accessibility
  trigger (bottom: 20px) at bottom: 80px (↓) and bottom: 128px (↑).
• z-index: 1500 — above the modal overlay (1000), below the accessibility
  trigger (2100) and notification drawer (9998).

Styling
───────
• Glassmorphism: var(--glass-bg) + backdrop-filter blur, matching the
  existing design language of glass-card, .glass-nav, and the
  accessibility trigger.
• 40 × 40 px circles on desktop; 36 × 36 px on mobile (≤768 px).
• Hover: fills with var(--green), scale(1.12), teal glow shadow.
• focus-visible outline for keyboard accessibility.
• CSS transitions on opacity, transform, background, and box-shadow.

Accessibility
─────────────
• aria-label="Scroll to top / Scroll to bottom" on both buttons.
• Keyboard-operable (focus-visible ring).
• Buttons are transparent to pointer events when hidden (pointer-events:none),
  so they never intercept clicks while invisible.

Files changed
─────────────
• index.html      — two <button> elements before </body>
• src/styles.css  — .scroll-nav-btn styles + responsive overrides
• src/app.js      — initScrollNav() IIFE inside DOMContentLoaded;
                    regenx:viewchanged event fired from showView()
• scripts/test-scroll-buttons.mjs — 17 test cases, 25 assertions

Tests: 25 passed, 0 failed.

Closes Shruti070107#527
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.

[FEATURE] Add scroll-to-top and scroll-to-bottom floating buttons for long dashboard pages

1 participant