Smooth Scroll

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

当前为 2024-11-22 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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