Vue.js directive that enhance your Modal Window, support drag, resize and maximize.
vue-directive-window
requires your Node.js version >= 8.
There are two ways of installation, from CDN and from npm, you can choose which you like.
<script src="https://unpkg.com/vue-directive-window/dist/vue-directive-window.umd.min.js"></script>
npm install vue-directive-window
npm start
vue-directive-window
provides two ways to use:
- Vue Custom Directive
- general javascript class library
<template>
<div v-window="windowParams">
<!-- container content -->
</div>
</template>
<script>
import VueDirectiveWindow from 'vue-directive-window';
Vue.use(VueDirectiveWindow); // When you take the CDN way, you don't need to import anything; you may use `Vue.use(window['vue-directive-window'])` instead.
export default {
data() {
return {
windowParams: {
movable: false,
resizable: ['left', 'left-top'],
},
};
},
}
</script>
<div class="demo-window" v-window="windowParams">
<!-- container content -->
</div>
import { enhanceWindow } from 'vue-directive-window'; // When you take the CDN way, you may use `const enhanceWindow = window['vue-directive-window'].enhanceWindow;` instead.
const windowParams = {
movable: false
resizable: ['left', 'left-top']
};
enhanceWindow(document.querySelector('.demo-window'), windowParams);
IE10 | IE11 | Chrome |
---|---|---|
OK | OK | OK |
- Type:
Number
- Default:
100
- Description: window's minimum width(px)
- Type:
Number
- Description: window's maximum width(px)
- Type:
Number
- Default:
100
- Description: window's minimum height(px)
- Type:
Number
- Description: window's maximum height(px)
- Type:
Boolean
/String
- Default:
true
- Accepted Values:
true
/false
/'horizontal'
/'vertical'
- Description: Is drag feature available; when set
movable
to'vertical'
, users will be only allow to make vertical drag; for the same reason,'horizontal'
means only allow horizontal drag; when settrue
, both directions are available.
- Type:
Boolean
/Array
- Default:
true
- Accepted Values:
left-top
/left-bottom
/left
/right-top
/right-bottom
/right
/top
/bottom
- Description: is resize feature available; when it is
true
, it means you could resize the window from every eight directions; when it is an Array value which contain String value, like['left', 'left-top']
you could resize the window only from targeted directions.
- Type:
String
/Element
- Description: custom drag handler. When it is
null
, you could move the window by dragging every inch of this window. Otherwise, when it is a String value,vue-directive-window
will usedocument.querySelector(customMoveHandler)
to get the handler's Element; in that case, you could move the window only by dragging the handler.
- Type:
String
/Element
- Description: maximize feature's handler. When it is a String value,
vue-directive-window
will usedocument.querySelector(customMoveHandler)
to get the handler.
- Type:
Function
- Description: window maximizeCallback function; there is one parameter, which means if it is current maximize(Boolean).
- Type:
Function
- Description: triggers when drag&move start.
- Type:
Function
- Description: triggers multiple times during drag&move going.
- Type:
Function
- Description: triggers when drag&move end.
👤 Array Huang
- Github: @Array-Huang
Copyright © 2019 Array Huang.
This project is MIT licensed.