0.1.2 • Published 3 years ago

vue-removed-hook-mixin v0.1.2

Weekly downloads
84
License
MIT
Repository
github
Last release
3 years ago

vue-removed-hook-mixin

Adds a removed hook to components, signalling $el's removal from the DOM.

Usage

// 1) Use the mixin in a single component.
import addRemovedHook from "vue-removed-hook-mixin";
export default {
    mixins: [addRemovedHook],

    // ...

    removed() {
        // this.$el is no longer a descendant of document.body.
    }
}

// 2) Apply the mixin to all components.
import addRemovedHook from "vue-removed-hook-mixin";
Vue.mixin(addRemovedHook);

Rationale

The built in destroyed hook is called before a component is fully transitioned out of view, which is a problem if destroying a non-Vue component changes how it looks. For instance, an interactive map, once destroyed, may remove all its tiles and becomes an unsightly grey box. Detecting the end of transitions is unreliable, so I opted to wait until the component's root element was removed from the DOM.

Discussion

License

MIT

0.1.2

3 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago