Skip to content

Observer options

Observe visibility, DOM mutations, or size when an interaction needs information from the browser. Configure only the observers you use on that element.

Observer directives support b-options, a synchronous object keyed by their attribute name. Base-name options apply first, then full-name options, then boolean dot modifiers. Options are read at hydration, not reactively retargeted. This is an observer-specific API, not a restoration of general legacy options for model/event/mask directives.

<div b-options="{ 'b-on-enter': {
root: '#scroller', rootMargin: '20px', threshold: [0, 0.5, 1]
} }"
b-on-enter.once.debounce="console.log($entry)"></div>
<div b-options="{ 'b-on-attrs': {
target: '#observed', subtree: false,
attributeFilter: ['data-theme'], attributeOldValue: true
} }"
b-on-attrs="console.log($mutations)"></div>
<div b-options="{ 'b-on-resize': { box: 'border-box', debounce: 250 } }"
b-on-resize.document="console.log($size, $entry)"></div>
OptionMeaning
rootElement/Document reference, selector, or null for the viewport (default).
rootMarginNative CSS length/percentage syntax.
thresholdNumber or array between 0 and 1.
.onceStop after the first delivered matching callback.

Enter/exit follow isIntersecting. Thresholds control native notification boundaries, not an additional percentage filter.

OptionMeaning
targetElement/Document/Text reference or selector; defaults to the directive element.
subtreeDefaults to true for existing v4 behavior; set false for direct-only observation. .subtree forces true.
attributeFilter, attributeOldValueAttribute-observer options; the old-value flag defaults to false.
characterDataOldValueText-observer option; defaults to false.

Added/removed observers filter childList records. Text observers watch characterData, not arbitrary textContent replacements.

Option or bindingMeaning
.document or document: trueObserve the owner document’s documentElement.
boxcontent-box (default), border-box, or device-pixel-content-box; passed to observe.
$size.width, $size.heightThe selected measurement, accounting for vertical writing modes. Device-pixel units are physical pixels.
$entryNative resize entry.

Missing nondefault box measurements report an error instead of silently supplying a different box.

Debounce settingDelay
.debounce or debounce: true100ms.
Numeric debounceA non-negative delay.
False or absentRun immediately.

A dot modifier overrides numeric configuration. Mutation debounce accumulates every matching record; intersection/resize use the latest matching entry. Disposal disconnects observers and cancels pending callbacks.

Selectors must resolve when hydrated. Invalid options throw explicitly. Intersection/ResizeObserver require native browser support or an application polyfill; native constructor validation governs CSS margins and platform support.