CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-better-scroll--mouse-wheel

A TypeScript plugin for BetterScroll that provides enhanced mouse wheel scrolling capabilities with configurable speed, direction, easing, and boundary damping on PC platforms.

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-5/

Dynamic Content Scroller

Build a scrollable container that automatically adjusts its scroll boundaries when content is dynamically added or removed through DOM manipulation.

Problem Description

Create a scrollable list component that handles dynamic content updates. The component should:

  1. Initialize a smooth scrolling container for a list of items
  2. Automatically recalculate scroll boundaries when items are added or removed from the DOM
  3. Maintain proper scrolling behavior as the content changes dynamically

The solution should handle scenarios where JavaScript code adds new elements, removes existing elements, or modifies the DOM structure of the scrollable content area.

Requirements

  • Initialize a scroll container that wraps a list of items
  • Enable automatic detection and handling of DOM changes within the scrollable area
  • Ensure the scroll boundaries update correctly when content is added or removed
  • The scroller should work smoothly on both mobile and desktop environments

Test Cases

  • Adding a new item to the list updates the scroll boundaries automatically @test
  • Removing an item from the list updates the scroll boundaries automatically @test
  • The scroller maintains proper boundaries after multiple rapid DOM changes @test

Implementation

@generates

API

/**
 * Creates a dynamic scrolling container that automatically adjusts to DOM changes
 *
 * @param {string|HTMLElement} wrapper - The wrapper element selector or DOM element
 * @param {Object} options - Configuration options
 * @returns {Object} The scroll instance with control methods
 */
function createDynamicScroller(wrapper, options) {
  // Implementation
}

/**
 * Adds a new item to the scrollable list
 *
 * @param {Object} scroller - The scroll instance
 * @param {string} itemText - Text content for the new item
 */
function addItem(scroller, itemText) {
  // Implementation
}

/**
 * Removes an item from the scrollable list
 *
 * @param {Object} scroller - The scroll instance
 * @param {number} index - Index of item to remove
 */
function removeItem(scroller, index) {
  // Implementation
}

module.exports = {
  createDynamicScroller,
  addItem,
  removeItem
};

Dependencies { .dependencies }

better-scroll { .dependency }

Provides smooth scrolling with automatic DOM observation capabilities.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-better-scroll--mouse-wheel

tile.json