David-Desmaisons / Vue.resize

Vue directive to detect resize events with deboucing and throttling capacity.
MIT License
326 stars 36 forks source link
resize-events vue-directive vuejs2

Vue.resize

GitHub open issues GitHub closed issues Npm download Npm version vue2 MIT License

Vue directive to detect HTML resize events based on CSS Element Queries with debouncing and throttling capacity.

Demo

demo gif

Typical usage

Simple

Use this option when you need to receive all the resize events.

The onResize function will be called each time the element resizes with the corresponding HTML element as only argument.

<div v-resize="onResize">

Throttle

Use throttle when you need to rate-limit resize events frequency.

Debounce

Use debounce when you only need to be notified when resize events ends.

Initial

Use this option to receive the resize callback right after the element is mounted on the DOM and visible.

<div v-resize.initial="onResize">

Installation

// ES6
import resize from 'vue-resize-directive'
//...
export default {
    directives: {
        resize,
    }
//...

// ES5
var resize = require('vue-resize-directive')