Smooth Scroll

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

目前為 2024-11-22 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
DXRK1E
評價
0 0 0
版本
2.3
建立日期
2024-07-23
更新日期
2024-11-22
尺寸
10.5 KB
授權條款
MIT
腳本執行於
所有網站

🖱️ 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