Home > widget-integration > FilterController > initSwatchTooltipScrollHandler

FilterController.initSwatchTooltipScrollHandler() method

Initializes scroll handlers for swatch tooltips. Attaches scroll event listeners to hide tooltips when page scrolls.

This method: - Iterates through all swatch options in the container - Prevents duplicate listeners using WeakSet tracking - Attaches touchstart and click events to trigger scroll handler - Ensures tooltips hide when user scrolls the page

Signature:

protected initSwatchTooltipScrollHandler(container: HTMLElement): void;

Parameters

Parameter

Type

Description

container

HTMLElement

The product item container element

Returns:

void

Remarks

Uses a WeakSet to track which labels have been processed to prevent duplicate event listener registration. This is important for performance and avoiding memory leaks when the method is called multiple times.

Example

Override to customize tooltip scroll behavior:

window.boostWidgetIntegration.extend('FilterController', (FilterController) => {
  return class CustomFilterController extends FilterController {
    protected initSwatchTooltipScrollHandler(container) {
      super.initSwatchTooltipScrollHandler(container);

      // Add custom scroll threshold before hiding
      container.querySelectorAll('.boost-sd__tooltip-content').forEach(tooltip => {
        tooltip.dataset.scrollThreshold = '50';
      });
    }
  };
});