Flarum (2.x)
    Preparing search index...

    The PostStream component displays an infinitely-scrollable wall of posts in a discussion. Posts that have not loaded will be displayed as placeholders.

    • discussion
    • stream
    • targetPost
    • onPositionChange

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _onUserInteraction: (() => void) | null | undefined

    The attributes passed into the component.

    calculatePositionTimeout: Timeout | undefined
    discussion: any
    element: Element

    The root DOM element for the component.

    observedElements: Set<any> | null | undefined
    resizeObserver: ResizeObserver | null | undefined
    scrollListener: ScrollListener | undefined
    settling: boolean | undefined
    settlingHardTimer: Timeout | null | undefined
    settlingStabilityTimer: Timeout | null | undefined
    settlingTarget:
        | { number: number }
        | { index: number; reply?: boolean }
        | null
        | undefined
    state: undefined

    Class component state that is persisted between redraws.

    Updating this will not automatically trigger a redraw, unlike other frameworks.

    This is different to Vnode state, which is always an instance of your class component.

    This is undefined by default.

    stream: any

    Methods

    • Returns a jQuery object for this component's element. If you pass in a selector string, this method will return a jQuery object, using the current element as its buffer.

      For example, calling component.$('li') will return a jQuery object containing all of the li elements inside the DOM element of this component.

      Parameters

      • Optionalselector: string

        a jQuery-compatible selector string

      Returns JQuery

      the jQuery object for the DOM node

    • Begin settling mode for the given target. Fully tears down any in-progress settling first to avoid listener and timer leaks on consecutive jumps, then arms fresh listeners and timers.

      Parameters

      • target: { number: number } | { index: number; reply?: boolean }

      Returns void

    • Work out which posts (by number) are currently visible in the viewport, and fire an event with the information.

      Parameters

      • top: number = window.scrollY
      • options: { fallbackToTarget?: boolean } = {}

        When fallbackToTarget is true and the DOM scan finds no loaded post with a data-number, the settling target's post number is used as the start. This allows an immediate URL emit right after a programmatic scroll lands, before async content has finished loading.

      Returns void

    • Disconnect the ResizeObserver, end settling mode, and release tracked data. Called from onremove to prevent memory leaks.

      Passes updatePosition: false to endSettling so that no history entry is written after the user has already navigated away from this discussion.

      Returns void

    • Compute which post numbers are currently visible in the viewport, without emitting anything. Pure calculation.

      Parameters

      • top: number = window.scrollY

      Returns { endNumber: number | undefined; startNumber: number | undefined }

    • Exit settling mode: stop watching for layout shifts, remove listeners, clear timers, and optionally update the URL/scrubber to match the final viewport.

      Parameters

      • options: { updatePosition?: boolean } = {}

        updatePosition defaults to true (normal end-of-settling reconciliation). Pass false when called from the unmount path so no stale history entry is written after the user has already navigated away.

      Returns void

    • Re-scroll to the locked target post. Uses the same offset logic as scrollToItem's post-load adjustment. Called synchronously from the ResizeObserver callback so the correction is applied before the browser paints, preventing visible flicker.

      Returns void

    • Resolve a definitive post number from the current settling target, for use as an immediate-emit fallback when the DOM scan finds no loaded post.

      Returns undefined when no number can be determined (placeholder targets, reply targets) — callers should skip the emit in that case.

      Returns number | undefined

    • Scroll down to a certain post by index.

      Parameters

      • index: number
      • animate: boolean
      • reply: boolean

        Whether or not to scroll to the reply placeholder.

      Returns JQueryDeferred<any>

    • Scroll down to the given post.

      Parameters

      • $item: JQuery<HTMLElement>
      • animate: boolean
      • force: boolean

        Whether or not to force scrolling to the item, even if it is already in the viewport.

      • reply: boolean

        Whether or not to scroll to the reply placeholder.

      Returns JQueryDeferred<any>

    • Set up a ResizeObserver that watches .PostStream-item elements for size changes. During the "settling" phase (after a programmatic scroll), any observed resize triggers an immediate re-scroll to the target post so the viewport stays locked on it while asynchronous content loads.

      Returns void