vue-mutation-observer

VueJS directive to observe changes in DOM use MutationObserver API
35,075 11
Install
npm install vue-mutation-observer
Latest Version:0.1.2
Vue:2
License:MIT
Last Updated:Aug 13, 2018
Links: GitHub  ·  npm
Maintainer: pnkbizz

vue-mutation-observer

VueJS directive to observe changes in DOM use MutationObserver API

Install

npm install vue-mutation-observer

or

yarn add vue-mutation-observer

CommonJS

You can use any build tool which supports commonjs:

// register globally
const observer =  require('vue-mutation-observer');
Vue.use(observer)

// or for a single instance
const { observer } = require('vue-mutation-observer');
new Vue({
  directives: { observer }
})

Or in ES2015:

// register globally
import observer from 'vue-mutation-observer'
Vue.use(observer)

// or for a single instance
import { observer } from 'vue-mutation-observer'
new Vue({
  directives: { observer }
})

Usage

Use v-observer directive to observe DOM mutations in node and it's children.

<div v-observer:subtree.childList="handler">
  // some content here
</div>

import { observer } from 'vue-mutation-observer'

export default {
  directives: { observer },
  methods: {
    handler (mutations) { console.log(mutations) }
  }
}

Arguments

Argument Description
subtree Extend monitoring to the entire subtree of node. All of the other properties are then extended to all of the nodes in the subtree instead of applying solely to the target node.

Modifiers

Modifier Description
characterData Add properties characterData and characterDataOldValue to observer configuration
attributes Add properties attributes and attributeOldValue to observer configuration
childList Add property childList to observer configuration

If no modifiers is define - all properties in config will be defines as true. MutationObserver configuration

Value

Value may be a function, which handle your mutation or an object with two properties: callback and config.

Related Packages

nuxt-keen-slider

Best, lightweight Keen Slider for best web performance

28,277 14
vue

The progressive JavaScript framework for building modern web UI.

588,019,132 54,801
vue
@vueuse/shared
372,738,348 22,398
@vueuse/core

Collection of essential Vue Composition Utilities

367,188,523 22,398
@vitejs/plugin-vue

The official plugin for Vue SFC support in Vite.

333,357,380 686

Version History

Version Released License
0.1.2 MIT
0.1.1 MIT
0.1.0 MIT