Smooth Scroll

Universal smooth scrolling for mouse wheel only. Touchpad uses native scrolling.

Versione datata 22/11/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Autore
DXRK1E
Valutazione
0 0 0
Versione
2.3
Creato il
23/07/2024
Aggiornato il
22/11/2024
Dimensione
10,5 KB
Licenza
MIT
Applica a
Tutti i siti

🖱️ Smooth Scroll

A lightweight and efficient userscript that enhances scrolling behavior in web browsers by providing buttery-smooth scrolling for mouse wheel users while preserving native touchpad scrolling.

✨ Features

  • Intelligent Device Detection: Automatically distinguishes between mouse wheel and touchpad input
  • Adaptive Scroll Physics: Dynamic acceleration and smoothing based on scroll speed and context
  • High Performance: Optimized animation frame handling with refresh rate synchronization
  • Native Touchpad Support: Automatically falls back to native scrolling for touchpad users
  • Smart Element Detection: Identifies and handles scrollable elements correctly
  • Minimal Impact: No visual changes or interference with website layouts
  • Universal Compatibility: Works on most websites (with configurable exceptions)

⚙️ Technical Details

Scroll Physics

  • Smoothness: Variable smoothing factor based on scroll speed (0.8)
  • Acceleration: Progressive acceleration with direction memory (0.25)
  • Refresh Rate: Adaptive between 30-144 FPS
  • Delta Threshold: Minimum scroll delta of 0.5px
  • Sub-pixel Handling: Accurate sub-pixel accumulation for smoother motion

Device Detection

  • Delta size analysis
  • Timing pattern recognition
  • Scroll consistency checking
  • Mode-based input classification

Performance Features

  • RequestAnimationFrame optimization
  • Efficient element caching
  • Smart scroll accumulation
  • Direction-aware acceleration
  • Adaptive refresh rate synchronization

🚫 Excluded Sites

  • YouTube (youtube.com)
  • Gmail (mail.google.com)

💡 Usage Notes

Best Used With

  • Mouse wheel scrolling
  • Regular web browsing
  • Long-form content
  • Infinite scroll pages

Not Recommended For

  • Gaming websites
  • Real-time applications
  • Precise scrolling tasks
  • Timeline scrubbing

🔧 Configuration

Default settings optimized for modern mice:

{
    smoothness: 0.8,        // Higher = smoother, but more latency
    acceleration: 0.25,     // Lower = more consistent speed
    minDelta: 0.5,         // Minimum scroll threshold
    maxRefreshRate: 144,   // Maximum FPS limit
    minRefreshRate: 30,    // Minimum FPS limit
    defaultRefreshRate: 60 // Fallback FPS
}

🌟 Advantages

  1. Improved Reading Experience

    • Smoother content flow
    • Reduced motion sickness
    • Better tracking of content
  2. Smart Adaptability

    • Device-specific behavior
    • Context-aware scrolling
    • Direction-aware physics
  3. Performance Focused

    • Minimal CPU usage
    • No memory leaks
    • Efficient animation loops

📝 Technical Implementation

The script uses several advanced techniques:

  • RAF Scheduling: Optimized requestAnimationFrame usage for smooth animations
  • Delta Normalization: Smart handling of different scroll delta modes
  • Element Detection: Efficient scrollable element identification and handling
  • State Management: Clean state tracking with WeakMap implementation
  • Error Recovery: Graceful error handling and scroll state recovery

🤝 Compatibility

Works with:

  • Modern browsers (Chrome, Firefox, Edge, Safari)
  • Most website frameworks
  • Infinite scroll implementations
  • Dynamic content loading
  • Standard overflow containers

⚠️ Known Limitations

  1. May not work optimally on:

    • WebGL heavy sites
    • Custom scroll implementations
    • Some single-page applications
    • Sites with custom scroll handlers
  2. Performance considerations:

    • High refresh rate monitors may need tuning
    • Very long pages might need additional optimization
    • Some browsers may handle acceleration differently