
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
vue3-v-resize
Advanced tools
Resize observer for Vue.
Detect size changes of DOM elements. Support Vue's directive and component.
ResizeObservable API implementationvue3npm
npm install vue3-v-resize
<template>
<div id="app">
<!-- directives -->
<div v-resize:50.immediate="onResize">
Listened to elements
</div>
<!-- Components -->
<ResizeComponent @resize="onResize" :delay="100" :disabled="disabled">
<div>Listened to elements</div>
</ResizeComponent>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { ResizeComponent, resizeDirective as vResize } from 'vue3-v-resize'
const disabled = ref(false)
function onResize({ width, height }, target) {
console.log(target, width, height)
}
</script>
// main.js
import Resizer from 'vue3-v-resize'
// vue@3.x
const app = createApp(App)
app.use(Resizer, {
// Custom command names and component names
directive: 'resize',
component: 'ResizeComponent'
})
<script setup>
import { ref } from 'vue'
import {
ResizeComponent,
resizeDirective as vResizeObserver //You can change the directive name, the default: `v-resize,
} from 'vue3-v-resize'
// OR
// import Resizer from 'v-resize-observer'
// const ResizeComponent = Resizer.component
// const vResize = Resizer.directive
function onResize({ width, height }, target) {
console.log(target, width, height)
}
</script>
<template>
<div id="app">
<!-- directives -->
<div v-resize-observer:100="onResize">
Listened to elements
</div>
<!-- Components -->
<ResizeComponent @resize="onResize">
<div>Listened to elements</div>
</ResizeComponent>
</div>
</template>
立即执行一次callback
| Parameter | Type | Default | Description |
|---|---|---|---|
target | string, HTMLElement | - | Target elements to listen to |
delay | number | 150 | Delayed execution time |
immediate | boolean | false | executed immediately |
disabled | boolean | false | disable listening |
resize | function | - | Callback function to listen for changes in element size |
resize(data, target)
data : elements size { width, height }target : Listening elementsdirectiveThe directive default name is
v-resize, if you want to change it, you can specify it when you import it.
<div v-resize="onResize" />
<div v-resize:100="onResize" />
<div v-resize:100.immediate="onResize" />
<!-- No limit on trigger frequency -->
<div v-resize:0="onResize" />
Parameter:
arg: => delayvalue: => resizemodifiers.immediateComponent<ResizeComponent target="#app" :delay="0" disabled="false" @resize="onResize">
<div>Listened to elements</div>
</ResizeComponent>
target: The target element to listen to, the default current element.delay: Delay execution time, default: 150.immediate: Execute immediately, default: false.disabled: disable listening, default: false.resize: Triggered when listening for element size changes.FAQs
Vue 3 resize observer with debounce
The npm package vue3-v-resize receives a total of 7 weekly downloads. As such, vue3-v-resize popularity was classified as not popular.
We found that vue3-v-resize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.