Smooth Scroll

Enables smooth page scrolling using JavaScript. Improved from an initial concept by Winceptor.

这些是代码更新过的版本。 显示所有版本

  • v2.4 2025-01-29

    Changelog

    Version 2.4

    • Major Refactor: Completely restructured the codebase for better organization and readability.
    • Settings Object: Introduced a SmoothScroll.settings object to easily configure scroll behavior.
    • WeakMap for State: Utilized WeakMap to store per-element scrolling data, preventing memory leaks.
    • Animation Duration: Added animationDuration to limit the maximum time for a smooth scroll animation.
    • Scroll Threshold: Added scrollThreshold to prevent animation on small scroll events.
    • Passive Event Listeners Option: Added a setting (passiveEventListeners) to allow users to choose if they want to use passive event listeners or not.
    • Error Handling in Style Retrieval: Added error handling when fetching style properties.
    • String.encamel Polyfill: Added a polyfill for older browsers missing the String.encamel method.
    • Code Formatting: Improved code formatting, code comments for better readability.
    • Version Update: Updated to version 2.4
    • Grant Update: Added @grant none since the script doesn't use any GM functions.
  • v2.3 2024-11-22

    Version 2.3

    • Added scroll pattern analysis for better device detection
    • Improved scroll physics and acceleration curves
    • Fixed up/down jitter issues
    • Enhanced subpixel accuracy
    • Added directional scroll handling
    • Fine-tuned performance parameters
  • v2.1 2024-11-22

    Smooth Scroll Minor Update

    Changelog (v2.1)

    Added

    • Support for Touchpad.
    • Added handlers for gesture events.
    • Added progressive momentum based on consecutive scroll events.
    • The script now automatically adjusts its behavior based on whether it detects touchpad or mouse wheel input
    • Provides smoother, more natural feeling scrolling for touchpad users

    Enhanced

    • Prevents default gesture behavior that might interfere with smooth scrolling
    • Adjusted smoothness calculation for touchpad input
  • v2.0 2024-11-18

    Enhanced Smooth Scroll Documentation

    Changelog (v2.0)

    Added

    • Class-based architecture for better code organization and maintainability
    • WeakMap-based state management to prevent memory leaks
    • Touch device support for mobile compatibility
    • Visibility change detection to cleanup scrolling when tab is hidden
    • Debug mode for easier troubleshooting
    • Configurable settings object for easy customization
    • Support for nested scrollable elements
    • Text selection detection to prevent scroll interference
    • Proper handling of different scroll modes (pixel, line, page)
    • Error recovery system for failed scroll attempts
    • Frame rate optimization with configurable limits
    • Subpixel scrolling accumulation for smoother motion

    Changed

    • Completely refactored code structure for better maintainability
    • Improved scroll animation algorithm for smoother motion
    • Enhanced scroll target detection logic
    • Better event listener management
    • More efficient frame rate calculation
    • Improved cross-browser compatibility
    • Better handling of scroll acceleration

    Fixed

    • Memory leaks from unbounded scroll animations
    • Scroll lockups on rapid direction changes
    • Nested scrollable elements conflicts
    • Cross-browser compatibility issues
    • Frame rate inconsistencies
    • Subpixel rounding errors
    • Event listener cleanup

    Removed

    • Global variable pollution
    • Redundant scroll calculations
    • Unnecessary DOM traversal
    • Legacy browser workarounds
    • Unused utility functions
  • v1.4 2024-07-28

    Smooth Scroll Function Changelog

    Version 1.4

    Enhancements and Fixes

    • Fixed Calculation Issues:

      • Improved calculations for smooth scrolling, ensuring consistent behavior across different pages.
      • Adjusted the logic for ScrollPixels and ScrollSubpixels to ensure proper handling and calculation.
    • Improved Scroll Handling:

      • Ensured the script properly handles different scrolling behaviors on various websites.
      • Added checks to handle cases where scrolling might get stuck.
    • Handled Edge Cases:

      • Added additional checks in CanScroll and HasScrollbar to handle edge cases.
      • Enhanced logic to ensure smooth scrolling even on pages with unusual scrolling behaviors.
    • Performance Improvements:

      • Optimized performance by refining the RequestAnimationUpdate function.
      • Ensured better frame rate calculations to maintain smooth animations.
    • Error Handling:

      • Added error handling mechanisms to prevent the script from breaking on certain pages.
      • Ensured the script fails gracefully when encountering unexpected scenarios.
    • General Code Cleanup:

      • Cleaned up and organized the code for better readability and maintainability.
      • Removed redundant code and improved comments for clarity.

    Known Issues

    • Compatibility:

      • The script may still encounter issues on websites with highly customized scrolling behaviors.
      • Further testing and adjustments may be required for specific edge cases.
    • Performance on Low-End Devices:

      • While performance improvements have been made, low-end devices may still experience some lag during smooth scrolling.
  • v1.3 2024-07-23