vue-resizesensor

0.3.0 • Public • Published

vue-resizesensor

What's this ?

Vue component which provides element resize event. Based on ResizeSensor of css-element-queries

Requirement

Vue >= 2.3.0

USAGE

Vue.component("resize-sensor", require("vue-resizesensor"));
 
const MyComponent = Vue.extend({
    template: `
        <div style="display: relative;">
            <resize-sensor @resized="onResize" :debounce="50"></resize-sensor>
            <div>
                {{ width }} x {{ height }}
            </div>
        </div>
    `,
    data: function() {
        return { width: 0, height: 0 };
    },
    methods: {
        onResize: function() {
            this.width = this.$el.clientWidth;
            this.height = this.$el.clientHeight;
        }
    },
    attached: function() {
        this.width = this.$el.clientWidth;
        this.height = this.$el.clientHeight;
    }
});

NOTE: display of target element must be absolute or relative.

LICENSE

MIT

Readme

Keywords

Package Sidebar

Install

npm i vue-resizesensor

Weekly Downloads

14

Version

0.3.0

License

MIT

Unpacked Size

5.54 kB

Total Files

5

Last publish

Collaborators

  • iwata0303