1. vue-resize-directive
Vue.js 2.0 directive to detect element resize
vue-resize-directive
Package: vue-resize-directive
Created by: David-Desmaisons
Last modified: Tue, 28 Jun 2022 20:12:50 GMT
Version: 1.2.0
License: MIT
Downloads: 158,679
Repository: https://github.com/David-Desmaisons/Vue.resize

Install

npm install vue-resize-directive
yarn add vue-resize-directive

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.

  • With default timeout (150 ms):
 <div v-resize:throttle="onResize">
  • With custom timeout (in ms):
 <div v-resize:throttle.100="onResize">

Debounce

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

  • With default timeout (150 ms):
 <div v-resize:debounce="onResize">
  • With custom timeout (in ms):
 <div v-resize:debounce.50="onResize">

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

  • Available through npm:
  npm install vue-resize-directive --save
  • For Modules
 // ES6
import resize from 'vue-resize-directive'
//...
export default {
    directives: {
        resize,
    }
//...
  
// ES5
var resize = require('vue-resize-directive')
  • For <script> Include

    Just include Vueresize.js after ResizeSensor.js from css-element-queries and lodash.js script.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin