packages/vuepress-docs/docs/en-US/plugins/observe-dom.md
Enable detection of content and content child DOM changes. When the plugin is used and these DOM elements change, bs.refresh() will be triggered. The observe-dom plugin has the following features:
npm install @better-scroll/observe-dom --save
// or
yarn add @better-scroll/observe-dom
import BScroll from '@better-scroll/core'
import ObserveDOM from '@better-scroll/observe-dom'
BScroll.use(ObserveDOM)
new BScroll('.bs-wrapper', {
//...
observeDOM: true // init observe-dom plugin
})
:::warning
For version <= 2.0.6, because the internal implementation of the plugin uses MutationObserver, it cannot detect whether the load of the img Element is complete, so for images with uncertain heights inside the content, you need to wait for the image to load before calling bs.refresh() to recalculate the scrollable size. If the browser does not support MutationObserver, the fallback inside the plugin is to recalculate the scrollable size every second.
:::
:::tip In the v2.1.0 version, the observe-image plugin is added to detect the loading of the img tag, so the two can be combined to complement the autorefresh ability to update BetterScroll every time. :::