├── .gitignore ├── demo.gif ├── .babelrc ├── src ├── main.js ├── vue-better-slider │ ├── index.js │ ├── components │ │ ├── slider-item.vue │ │ └── slider.vue │ └── common │ │ └── js │ │ └── dom.js └── App.vue ├── .postcssrc.js ├── static └── package.json ├── vue-better-slider ├── package.json └── index.js ├── index.html ├── LICENSE ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log* 4 | /vue-better-slider -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openfe-openfe/vue-better-slider/HEAD/demo.gif -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [["env",{ 3 | "modules": false 4 | }], "stage-0"] 5 | } -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | 4 | new Vue({ 5 | el: '#app', 6 | render: h => h(App) 7 | }); -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "plugins": { 3 | "autoprefixer": { 4 | browsers:["> 1%", "last 20 versions", "not ie <= 8"] 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /src/vue-better-slider/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import IcSlider from './components/slider' 3 | import IcSliderItem from './components/slider-item' 4 | export { 5 | IcSlider, 6 | IcSliderItem 7 | } -------------------------------------------------------------------------------- /static/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-better-slider", 3 | "version": "1.1.1", 4 | "main": "index.js", 5 | "scripts": {}, 6 | "author": "songhao", 7 | "license": "MIT", 8 | "devDependencies": { 9 | "babel-preset-env": "^1.3.3", 10 | "babel-preset-stage-0": "^6.24.1", 11 | "vue": "^2.2.6" 12 | } 13 | } -------------------------------------------------------------------------------- /vue-better-slider/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-better-slider", 3 | "version": "1.1.0", 4 | "main": "index.js", 5 | "scripts": {}, 6 | "author": "songhao", 7 | "license": "MIT", 8 | "devDependencies": { 9 | "babel-preset-env": "^1.3.3", 10 | "babel-preset-stage-0": "^6.24.1", 11 | "vue": "^2.2.6" 12 | } 13 | } -------------------------------------------------------------------------------- /src/vue-better-slider/components/slider-item.vue: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 songhao 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 | 23 | -------------------------------------------------------------------------------- /src/vue-better-slider/common/js/dom.js: -------------------------------------------------------------------------------- 1 | export function hasClass(el, className) { 2 | let reg = new RegExp('(^|\\s)' + className + '(\\s|$)') 3 | return reg.test(el.className) 4 | } 5 | 6 | export function addClass(el, className) { 7 | if (hasClass(el, className)) { 8 | return 9 | } 10 | 11 | let newClass = el.className.split(' ') 12 | newClass.push(className) 13 | el.className = newClass.join(' ') 14 | } 15 | 16 | export function getData(el, name, val) { 17 | const prefix = 'data-' 18 | if (val) { 19 | return el.setAttribute(prefix + name, val) 20 | } 21 | return el.getAttribute(prefix + name) 22 | } 23 | 24 | let elementStyle = document.createElement('div').style 25 | 26 | let vendor = (() => { 27 | let transformNames = { 28 | webkit: 'webkitTransform', 29 | Moz: 'MozTransform', 30 | O: 'OTransform', 31 | ms: 'msTransform', 32 | standard: 'transform' 33 | } 34 | 35 | for (let key in transformNames) { 36 | if (elementStyle[transformNames[key]] !== undefined) { 37 | return key 38 | } 39 | } 40 | 41 | return false 42 | })() 43 | 44 | export function prefixStyle(style) { 45 | if (vendor === false) { 46 | return false 47 | } 48 | 49 | if (vendor === 'standard') { 50 | return style 51 | } 52 | 53 | return vendor + style.charAt(0).toUpperCase() + style.substr(1) 54 | } 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-better-slider", 3 | "version": "1.0.3", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "node build/server.js", 8 | "compile": "node build/compile.js && npm publish ./vue-better-slider" 9 | }, 10 | "author": "songhao", 11 | "license": "MIT", 12 | "dependencies": { 13 | "babel-core": "^6.24.0", 14 | "babel-loader": "^6.4.1", 15 | "babel-plugin-transform-runtime": "^6.23.0", 16 | "babel-preset-env": "^1.3.3", 17 | "babel-preset-es2015": "^6.24.0", 18 | "babel-preset-stage-0": "^6.22.0", 19 | "better-scroll": "^1.3.0", 20 | "clean-webpack-plugin": "^0.1.16", 21 | "connect-history-api-fallback": "^1.3.0", 22 | "css-loader": "^0.27.3", 23 | "eventsource-polyfill": "^0.9.6", 24 | "express": "^4.15.2", 25 | "extract-text-webpack-plugin": "^2.1.0", 26 | "file-loader": "^0.10.1", 27 | "friendly-errors-webpack-plugin": "^1.6.1", 28 | "html-webpack-plugin": "^2.28.0", 29 | "lodash": "^4.17.4", 30 | "opn": "^4.0.2", 31 | "postcss-loader": "^1.3.3", 32 | "rimraf": "^2.6.1", 33 | "semver": "^5.3.0", 34 | "shelljs": "^0.7.7", 35 | "style-loader": "^0.16.1", 36 | "stylus": "^0.54.5", 37 | "stylus-loader": "^2.1.1", 38 | "uglify-js": "^2.8.0", 39 | "uglifyjs-webpack-plugin": "^0.3.1", 40 | "url-loader": "^0.5.8", 41 | "vue": "^2.2.6", 42 | "vue-loader": "^11.3.3", 43 | "vue-router": "^2.3.0", 44 | "vue-template-compiler": "^2.2.6", 45 | "webpack": "^2.3.2", 46 | "webpack-dev-middleware": "^1.10.1", 47 | "webpack-hot-middleware": "^2.17.1" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 2 |