Smooth Scroll

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

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

作者
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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址