--- url: /reference/items/InViewOnce/js-api.md --- # JS API The `InViewOnce` class extends the [`InView` primitive](/reference/items/InView/js-api.html). As it inherits its API, make sure to have a look at its own API reference too. Unlike `InView`, it emits `in-view` only once and never emits `out-of-view`. ## Events ### `in-view` Emitted once, when the element first enters the viewport. The component then terminates and disconnects its observer, so the event never fires again. ```js onInViewOnceInView() { // the element entered the viewport for the first time } ``` ## Options ### `intersectionObserver` * Type: `object` * Default: `{ threshold: [0, 1] }` Options forwarded to the underlying [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options) instance created by the [`withMountWhenInView` decorator](https://js-toolkit.studiometa.dev/api/decorators/withMountWhenInView.html). Use it to adjust the `rootMargin`, `threshold` or `root` used to detect the viewport crossing. ```html