├── .gitignore ├── LICENSE ├── README.md ├── package.json └── src └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) mage3k 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-autosize 2 | 3 | A simple [Vue](https://github.com/vuejs/vue) directive for [autosize](https://github.com/jackmoore/autosize) 4 | 5 | ## usage 6 | 7 | ``` 8 | var Vue = require('vue') 9 | var VueAutosize = require('vue-autosize') 10 | 11 | Vue.use(VueAutosize) 12 | ``` 13 | 14 | ``` 15 | 16 | ``` 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-autosize", 3 | "version": "1.0.2", 4 | "description": "autosize for vue directive", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "textarea", 11 | "autosize", 12 | "vue", 13 | "directive" 14 | ], 15 | "author": "mage3k", 16 | "license": "MIT", 17 | "dependencies": { 18 | "autosize": "^4.0.0", 19 | "autosize-input": "^0.4.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | var autosize = require('autosize') 2 | var autoSizeInput = require('autosize-input') 3 | 4 | exports.install = function(Vue) { 5 | Vue.directive('autosize', { 6 | bind: function(el, binding) { 7 | var tagName = el.tagName 8 | if (tagName == 'TEXTAREA') { 9 | autosize(el) 10 | } else if (tagName == 'INPUT' && el.type == 'text') { 11 | autoSizeInput(el) 12 | } 13 | }, 14 | 15 | componentUpdated: function(el, binding, vnode) { 16 | var tagName = el.tagName 17 | if (tagName == 'TEXTAREA') { 18 | autosize.update(el) 19 | } else if (tagName == 'INPUT' && el.type == 'text') { 20 | autoSizeInput(el) 21 | } 22 | }, 23 | 24 | unbind: function(el) { 25 | autosize.destroy(el) 26 | } 27 | }) 28 | } 29 | --------------------------------------------------------------------------------