Package Exports
- kdu-resize
- kdu-resize/dist/kdu-resize.css
- kdu-resize/dist/kdu-resize.esm.js
- kdu-resize/dist/kdu-resize.umd.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kdu-resize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
kdu-resize
Detect DOM element resizing
Installation
npm install --save kdu-resize
Module import
⚠️ You need to include the package CSS:
import 'kdu-resize/dist/kdu-resize.css'
Then import the package and install it into Kdu:
import Kdu from 'kdu'
import KduResize from 'kdu-resize'
Kdu.use(KduResize)
Or:
import Kdu from 'kdu'
import { ResizeObserver } from 'kdu-resize'
Kdu.component('resize-observer', ResizeObserver)
Browser
<link rel="stylesheet" href="kdu-resize/dist/kdu-resize.css"/>
<script src="kdu.js"></script>
<script src="kdu-resize/dist/kdu-resize.min.js"></script>
The plugin should be auto-installed. If not, you can install it manually:
Kdu.use(KduResize)
Or:
Kdu.component('resize-observer', KduResize.ResizeObserver)
Usage
Add the <resize-observer>
inside a DOM element and make its position to something other than 'static'
(for example 'relative'
), so that the observer can fill it.
Listen to the notify
event that is fired when the above DOM element is resized.
Example
<template>
<div class="demo">
<h1>Hello world!</h1>
<resize-observer @notify="handleResize" />
</div>
</template>
<script>
export default {
methods: {
handleResize ({ width, height }) {
console.log('resized', width, height)
}
}
}
</script>
<style scoped>
.demo {
position: relative;
}
</style>