pronotron-tech-art-suite
    Preparing search index...

    Class PronotronIOHorizontalObserver

    PronotronIO - A custom intersection observer solution

    const pronotronIO = new PronotronIOHorizontalObserver();
    pronotronIO.setLastScroll( 0 );
    pronotronIO.addNode({
    ref: HTMLElement,
    dispatch: {
    onInViewport: ( normalizedPosition: number ) => console.log( "Element is in viewport", normalizedPosition ),
    onLeftEnter: () => console.log( "Element entered from left" ),
    onLeftExit: {
    dispatch: () => console.log( "Element exited from left" ),
    limit: 2
    },
    onRightEnter...,
    onRightExit...,
    onFastForward: "execute_both",
    },
    onRemoveNode: () => element.dataset.ioActive = "0",
    getBounds: () => {
    const { left, right } = element.getBoundingClientRect();
    const start = left + window.scrollX;
    const end = right + window.scrollX;
    return { start, end };
    }
    offset: 100, // In pixels, applied to both directions
    });
    // Recommended: wrap in a throttled handler for performance
    window.addEventListener( 'scroll', () => pronotronIO.handleScroll( window.scrollX ) );

    Hierarchy

    • PronotronIOEventDispatcher<HorizontalEvent>
      • PronotronIOHorizontalObserver
    Index

    Constructors

    • Parameters

      • nodeCountHint: number = 20

        To populate fixed typed array length, will be expanded if needed

      • useRounded: boolean = true

        Whether integers are used instead of floating-point numbers. Default is true.

      Returns PronotronIOHorizontalObserver

    Properties

    direction: "left" | "right" = "right"

    Current scroll direction (based on the last scroll value).

    Methods

    • Creates an IONode.

      Parameters

      • newNodeOptions: IONodeOptions<HorizontalEvent>

        IONode creation options

      Returns number | false

      false if error, IONode internal id if success

    • Handles scroll events and updates the current scroll direction, then recalculates intersections.

      Parameters

      • scrollValue: number

        Current scroll value

      Returns void

    • Removes an IONode by its ref PronotronIONodeRef

      Parameters

      • existingNodeRef: HTMLElement

        Reference passed while executing addNode()

      Returns void

    • Modifies the last scroll value

      Parameters

      • scrollValue: number

        Scroll value

      Returns void

    • Bulk updates all IONode positions. Should be executed when the layout changes, e.g.:

      • Screen resize
      • Resizing in-page elements (accordion, etc.)

      Parameters

      • maximumValue: number

        Maximum possible position (e.g., document.documentElement.scrollHeight).

      Returns void

    • Updates viewport layout data used in calculations. Should be called on:

      • Mobile viewport changes (status bar collapse/expand)
      • Pinch-zoom changes
      • Screen or in-page resizes

      Parameters

      • start: number

        Start position of the viewport.

      • end: number

        End position of the viewport.

      Returns void