├── .github └── dependabot.yml ├── .gitignore ├── LICENSE ├── README.md ├── components └── MultiDrawer.vue ├── index.js ├── multi-drawer-demo.gif └── package.json /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | versioning-strategy: lockfile-only 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 NativeScript-Vue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NativeScript-Vue Multi Drawer 2 | 3 | A plugin which provides a drawer component that supports multiple drawers. 4 | 5 | 6 | 7 | All drawers are optional, and can be configured individually. 8 | 9 | Features: 10 | * drawers on left, right, top and bottom 11 | * swipe to open 12 | * swipe to close 13 | * tap outside to close 14 | * progressively dim main content as the drawer is opened 15 | 16 | ## Quick Start 17 | 18 | ```bash 19 | $ npm i --save nativescript-vue-multi-drawer 20 | ``` 21 | 22 | 23 | ```diff 24 | // main.js 25 | import Vue from 'nativescript-vue' 26 | ... 27 | + import MultiDrawer from 'nativescript-vue-multi-drawer' 28 | + Vue.use(MultiDrawer) 29 | ``` 30 | 31 | Optionally set default options by passing `options` when installing the plugin: 32 | ```js 33 | Vue.use(MultiDrawer, { 34 | // override any option here 35 | // for example enable debug mode 36 | debug: true 37 | }) 38 | ``` 39 | 40 | For the available options check [the source of defaultOptions](https://github.com/nativescript-vue/nativescript-vue-multi-drawer/blob/98df9f4d342ebae12c761e45f4f23f68c15fb094/index.js#L5-L76) 41 | 42 | ```xml 43 | 44 | 45 | 47 | 48 | 50 | 51 | 53 | 54 | 56 | 57 | 58 | 59 | ``` 60 | 61 | The component will only enable drawers that have contents in them, so if you only need a left and a right side drawer, you can just remove the top and bottom slots and it will work as expected. 62 | 63 | ### Opening a drawer from code 64 | 65 | Assign a ref to the Drawer component 66 | ```xml 67 | 68 | ``` 69 | 70 | And use `this.$refs.drawer.open(side)` where `side` is a string: `left`, `right`, `top` or `bottom`. 71 | 72 | ### Using v-model to toggle the drawer 73 | 74 | The drawer can be opened through v-model. This is useful as it allows controlling the drawer state with Vue's reactivity system. For example, the value of v-model could easily come from a vuex store. 75 | 76 | ```xml 77 | 78 | ``` 79 | 80 | ```js 81 | export default { 82 | data() { 83 | return { 84 | drawerState: false // closed 85 | } 86 | }, 87 | 88 | methods: { 89 | doStuff() { 90 | // do stuff 91 | this.drawerState = 'left' // this will open the left drawer 92 | } 93 | } 94 | } 95 | ``` 96 | -------------------------------------------------------------------------------- /components/MultiDrawer.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 387 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import mergeOptions from 'merge-options' 2 | 3 | import MultiDrawer from './components/MultiDrawer' 4 | 5 | export let defaultOptions = { 6 | debug: false, 7 | backdropColor: 'rgba(0, 0, 0, 0.7)', 8 | left: { 9 | width: '70%', 10 | height: null, 11 | backgroundColor: '#ffffff', 12 | canSwipeOpen: true, 13 | swipeOpenTriggerWidth: 30, 14 | swipeOpenTriggerHeight: null, 15 | swipeOpenTriggerMinDrag: 50, 16 | swipeCloseTriggerMinDrag: 50, 17 | swipeOpenTriggerProperties: {}, 18 | animation: { 19 | openDuration: 300, 20 | closeDuration: 300, 21 | }, 22 | translationOffsetMultiplier: -1, 23 | axis: 'X', 24 | }, 25 | right: { 26 | width: '70%', 27 | height: null, 28 | backgroundColor: '#ffffff', 29 | canSwipeOpen: true, 30 | swipeOpenTriggerWidth: 30, 31 | swipeOpenTriggerHeight: null, 32 | swipeOpenTriggerMinDrag: 50, 33 | swipeCloseTriggerMinDrag: 50, 34 | swipeOpenTriggerProperties: {}, 35 | animation: { 36 | openDuration: 300, 37 | closeDuration: 300, 38 | }, 39 | translationOffsetMultiplier: 1, 40 | axis: 'X', 41 | }, 42 | top: { 43 | width: null, 44 | height: '40%', 45 | backgroundColor: '#ffffff', 46 | canSwipeOpen: true, 47 | swipeOpenTriggerWidth: null, 48 | swipeOpenTriggerHeight: 50, 49 | swipeOpenTriggerMinDrag: 50, 50 | swipeCloseTriggerMinDrag: 50, 51 | swipeOpenTriggerProperties: {}, 52 | animation: { 53 | openDuration: 300, 54 | closeDuration: 300, 55 | }, 56 | translationOffsetMultiplier: -1, 57 | axis: 'Y', 58 | }, 59 | bottom: { 60 | width: null, 61 | height: '40%', 62 | backgroundColor: '#ffffff', 63 | canSwipeOpen: true, 64 | swipeOpenTriggerWidth: null, 65 | swipeOpenTriggerHeight: 30, 66 | swipeOpenTriggerMinDrag: 50, 67 | swipeCloseTriggerMinDrag: 50, 68 | swipeOpenTriggerProperties: {}, 69 | animation: { 70 | openDuration: 300, 71 | closeDuration: 300, 72 | }, 73 | translationOffsetMultiplier: 1, 74 | axis: 'Y', 75 | }, 76 | } 77 | 78 | export default function install(Vue, options) { 79 | if(options) { 80 | defaultOptions = mergeOptions(defaultOptions, options) 81 | } 82 | 83 | Vue.component('MultiDrawer', MultiDrawer) 84 | } 85 | -------------------------------------------------------------------------------- /multi-drawer-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativescript-vue/nativescript-vue-multi-drawer/2e0647e66b6481cc97f7ed3129fe8f49e1922488/multi-drawer-demo.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-vue-multi-drawer", 3 | "version": "0.0.4", 4 | "description": "A NativeScript-Vue component for creating multiple side drawers", 5 | "main": "index.js", 6 | "nativescript": { 7 | "plugin": { 8 | "vue": "true" 9 | } 10 | }, 11 | "files": [ 12 | "index.js", 13 | "components" 14 | ], 15 | "scripts": { 16 | "test": "echo \"Error: no test specified\" && exit 1" 17 | }, 18 | "keywords": [ 19 | "nativescript", 20 | "nativescript-vue", 21 | "drawer", 22 | "sidedrawer", 23 | "multi", 24 | "multiple" 25 | ], 26 | "author": "Igor Randjelovic", 27 | "license": "MIT", 28 | "dependencies": { 29 | "merge-options": "^2.0.0" 30 | } 31 | } 32 | --------------------------------------------------------------------------------