├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── .postcssrc.js ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── build ├── build.js ├── check-versions.js ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── dist └── vue-3d-menu.js ├── index.html ├── package.json ├── src ├── App.vue ├── Vue3dMenu │ ├── MenuItem.vue │ ├── Vue3dMenu.vue │ ├── assets │ │ └── topMenu.png │ ├── index.js │ └── lib │ │ ├── Animate.js │ │ ├── Deferred.js │ │ ├── ItemInfo.js │ │ ├── Queue.js │ │ ├── Rotate.js │ │ └── Tween.js └── main.js └── static └── .gitkeep /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-vue-jsx", "transform-runtime"] 12 | } 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parserOptions: { 6 | parser: 'babel-eslint' 7 | }, 8 | env: { 9 | browser: true, 10 | }, 11 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention 12 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 13 | extends: ['plugin:vue/essential'], 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'vue' 17 | ], 18 | // add your custom rules here 19 | rules: { 20 | // allow debugger during development 21 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | .DS_Store 61 | /package-lock.json 62 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | .vscode 40 | build 41 | config 42 | node_modules 43 | src 44 | static 45 | .babelrc 46 | .editorconfig 47 | .eslintignore 48 | .eslintrc.js 49 | .postcssrc.js 50 | index.html 51 | package-lock.json 52 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 谢爽 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 | # vue-3d-menu 2 | 3 | [![npm](https://img.shields.io/npm/v/vue-3d-menu.svg)](https://www.npmjs.com/package/vue-3d-menu) ![Github file size](https://img.shields.io/github/size/shalldie/vue-3d-menu/dist/vue-3d-menu.js.svg) 4 | 5 | Vue 的 3d 菜单组件。 6 | 效果参照 2013 版 miaov 官网右上角菜单。 7 | 8 | ## Examples 9 | 10 | ![vue-3d-menu](https://user-images.githubusercontent.com/9987486/38456467-918f76d2-3ab7-11e8-841e-04c2a51c765e.gif) 11 | 12 | [To see a demo.](https://shalldie.github.io/demos/vue-3d-menu/) 13 | 14 | ## Installation 15 | 16 | npm install vue-3d-menu 17 | 18 | ## Usage 19 | 20 | ```js 21 | import Vue from 'vue'; 22 | import Vue3dMenu from 'vue-3d-menu'; 23 | // let Vue3dMenu = window.Vue3dMenu; // window 24 | // let Vue3dMenu = require('vue-3d-menu'); // commonjs 25 | ``` 26 | 27 | ```js 28 | // regist 注册组件 29 | 30 | Vue.use(Vue3dMenu); // global 31 | 32 | // or 33 | 34 | new Vue({ 35 | el: 'body', 36 | components: { Vue3dMenu } // local 37 | }); 38 | ``` 39 | 40 | ```js 41 | // template: 42 | 46 | 47 | // data: 48 | data() { 49 | return { 50 | items: [{ title: '>_<#@!', click: ()=> alert('hello~') }] 51 | }; 52 | } 53 | ``` 54 | 55 | ## Support 56 | 57 | Chrome and Firefox 58 | 59 | # Api 60 | 61 | ## Properties 62 | 63 | An array of ItemInfo: `Array` 64 | 65 | ItemInfo: 66 | 67 | | Name | Type | Default | Description | 68 | | :---- | :--------: | :-----: | :----------------------------------------------------------------- | 69 | | title | `String` | `''` | The label of an item.
某一项显示的文字 | 70 | | click | `Function` | `null` | The callback when you click this item.
点某一项时候进行的回调 | 71 | 72 | # Enjoy it! :D 73 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | const ora = require('ora') 7 | const rm = require('rimraf') 8 | const path = require('path') 9 | const chalk = require('chalk') 10 | const webpack = require('webpack') 11 | const config = require('../config') 12 | const webpackConfig = require('./webpack.prod.conf') 13 | 14 | const spinner = ora('building for production...') 15 | spinner.start() 16 | 17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 18 | if (err) throw err 19 | webpack(webpackConfig, (err, stats) => { 20 | spinner.stop() 21 | if (err) throw err 22 | process.stdout.write(stats.toString({ 23 | colors: true, 24 | modules: false, 25 | children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build. 26 | chunks: false, 27 | chunkModules: false 28 | }) + '\n\n') 29 | 30 | if (stats.hasErrors()) { 31 | console.log(chalk.red(' Build failed with errors.\n')) 32 | process.exit(1) 33 | } 34 | 35 | console.log(chalk.cyan(' Build complete.\n')) 36 | console.log(chalk.yellow( 37 | ' Tip: built done.\n' + 38 | ' UMD module has been ready >_<#@!\n' 39 | )) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /build/check-versions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const chalk = require('chalk') 3 | const semver = require('semver') 4 | const packageConfig = require('../package.json') 5 | const shell = require('shelljs') 6 | 7 | function exec (cmd) { 8 | return require('child_process').execSync(cmd).toString().trim() 9 | } 10 | 11 | const versionRequirements = [ 12 | { 13 | name: 'node', 14 | currentVersion: semver.clean(process.version), 15 | versionRequirement: packageConfig.engines.node 16 | } 17 | ] 18 | 19 | if (shell.which('npm')) { 20 | versionRequirements.push({ 21 | name: 'npm', 22 | currentVersion: exec('npm --version'), 23 | versionRequirement: packageConfig.engines.npm 24 | }) 25 | } 26 | 27 | module.exports = function () { 28 | const warnings = [] 29 | 30 | for (let i = 0; i < versionRequirements.length; i++) { 31 | const mod = versionRequirements[i] 32 | 33 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 34 | warnings.push(mod.name + ': ' + 35 | chalk.red(mod.currentVersion) + ' should be ' + 36 | chalk.green(mod.versionRequirement) 37 | ) 38 | } 39 | } 40 | 41 | if (warnings.length) { 42 | console.log('') 43 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 44 | console.log() 45 | 46 | for (let i = 0; i < warnings.length; i++) { 47 | const warning = warnings[i] 48 | console.log(' ' + warning) 49 | } 50 | 51 | console.log() 52 | process.exit(1) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const config = require('../config') 4 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 5 | const packageConfig = require('../package.json') 6 | 7 | exports.assetsPath = function (_path) { 8 | const assetsSubDirectory = process.env.NODE_ENV === 'production' 9 | ? config.build.assetsSubDirectory 10 | : config.dev.assetsSubDirectory 11 | 12 | return path.posix.join(assetsSubDirectory, _path) 13 | } 14 | 15 | exports.cssLoaders = function (options) { 16 | options = options || {} 17 | 18 | const cssLoader = { 19 | loader: 'css-loader', 20 | options: { 21 | sourceMap: options.sourceMap 22 | } 23 | } 24 | 25 | const postcssLoader = { 26 | loader: 'postcss-loader', 27 | options: { 28 | sourceMap: options.sourceMap 29 | } 30 | } 31 | 32 | // generate loader string to be used with extract text plugin 33 | function generateLoaders(loader, loaderOptions) { 34 | const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] 35 | 36 | if (loader) { 37 | loaders.push({ 38 | loader: loader + '-loader', 39 | options: Object.assign({}, loaderOptions, { 40 | sourceMap: options.sourceMap 41 | }) 42 | }) 43 | } 44 | 45 | // Extract CSS when that option is specified 46 | // (which is the case during production build) 47 | if (options.extract && false) { 48 | return ExtractTextPlugin.extract({ 49 | use: loaders, 50 | fallback: 'vue-style-loader' 51 | }) 52 | } else { 53 | return ['vue-style-loader'].concat(loaders) 54 | } 55 | } 56 | 57 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 58 | return { 59 | css: generateLoaders(), 60 | postcss: generateLoaders(), 61 | less: generateLoaders('less'), 62 | sass: generateLoaders('sass', { indentedSyntax: true }), 63 | scss: generateLoaders('sass'), 64 | stylus: generateLoaders('stylus'), 65 | styl: generateLoaders('stylus') 66 | } 67 | } 68 | 69 | // Generate loaders for standalone style files (outside of .vue) 70 | exports.styleLoaders = function (options) { 71 | const output = [] 72 | const loaders = exports.cssLoaders(options) 73 | 74 | for (const extension in loaders) { 75 | const loader = loaders[extension] 76 | output.push({ 77 | test: new RegExp('\\.' + extension + '$'), 78 | use: loader 79 | }) 80 | } 81 | 82 | return output 83 | } 84 | 85 | exports.createNotifierCallback = () => { 86 | const notifier = require('node-notifier') 87 | 88 | return (severity, errors) => { 89 | if (severity !== 'error') return 90 | 91 | const error = errors[0] 92 | const filename = error.file && error.file.split('!').pop() 93 | 94 | notifier.notify({ 95 | title: packageConfig.name, 96 | message: severity + ': ' + error.name, 97 | subtitle: filename || '', 98 | icon: path.join(__dirname, 'logo.png') 99 | }) 100 | } 101 | } 102 | /** 103 | * 是否是 production 环境 104 | * 105 | */ 106 | exports.ifProduction = () => process.env.NODE_ENV === 'production'; 107 | -------------------------------------------------------------------------------- /build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const config = require('../config') 5 | const vueLoaderConfig = require('./vue-loader.conf') 6 | 7 | function resolve(dir) { 8 | return path.join(__dirname, '..', dir) 9 | } 10 | 11 | const createLintingRule = () => ({ 12 | test: /\.(js|vue)$/, 13 | loader: 'eslint-loader', 14 | enforce: 'pre', 15 | include: [resolve('src'), resolve('test')], 16 | options: { 17 | formatter: require('eslint-friendly-formatter'), 18 | emitWarning: !config.dev.showEslintErrorsInOverlay 19 | } 20 | }) 21 | 22 | module.exports = { 23 | context: path.resolve(__dirname, '../'), 24 | entry: { 25 | 'vue-3d-menu': utils.ifProduction() ? './src/Vue3dMenu/index.js' : './src/main.js' 26 | }, 27 | output: { 28 | path: config.build.assetsRoot, 29 | filename: '[name].js', 30 | library: 'Vue3dMenu', 31 | libraryExport: 'default', 32 | libraryTarget: utils.ifProduction() ? 'umd' : undefined, 33 | publicPath: process.env.NODE_ENV === 'production' 34 | ? config.build.assetsPublicPath 35 | : config.dev.assetsPublicPath 36 | }, 37 | resolve: { 38 | extensions: ['.js', '.vue', '.json'], 39 | alias: { 40 | 'vue$': 'vue/dist/vue.esm.js', 41 | '@': resolve('src'), 42 | } 43 | }, 44 | module: { 45 | rules: [ 46 | ...(config.dev.useEslint ? [createLintingRule()] : []), 47 | { 48 | test: /\.vue$/, 49 | loader: 'vue-loader', 50 | options: vueLoaderConfig 51 | }, 52 | { 53 | test: /\.js$/, 54 | loader: 'babel-loader', 55 | include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] 56 | }, 57 | { 58 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 59 | loader: 'url-loader', 60 | options: { 61 | limit: 10000, 62 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 63 | } 64 | }, 65 | { 66 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 67 | loader: 'url-loader', 68 | options: { 69 | limit: 10000, 70 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 71 | } 72 | }, 73 | { 74 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 75 | loader: 'url-loader', 76 | options: { 77 | limit: 10000, 78 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 79 | } 80 | } 81 | ] 82 | }, 83 | node: { 84 | // prevent webpack from injecting useless setImmediate polyfill because Vue 85 | // source contains it (although only uses it if it's native). 86 | setImmediate: false, 87 | // prevent webpack from injecting mocks to Node native modules 88 | // that does not make sense for the client 89 | dgram: 'empty', 90 | fs: 'empty', 91 | net: 'empty', 92 | tls: 'empty', 93 | child_process: 'empty' 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const webpack = require('webpack') 4 | const config = require('../config') 5 | const merge = require('webpack-merge') 6 | const path = require('path') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 11 | const portfinder = require('portfinder') 12 | 13 | const HOST = process.env.HOST 14 | const PORT = process.env.PORT && Number(process.env.PORT) 15 | 16 | const devWebpackConfig = merge(baseWebpackConfig, { 17 | module: { 18 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) 19 | }, 20 | // cheap-module-eval-source-map is faster for development 21 | devtool: config.dev.devtool, 22 | 23 | // these devServer options should be customized in /config/index.js 24 | devServer: { 25 | clientLogLevel: 'warning', 26 | historyApiFallback: { 27 | rewrites: [ 28 | { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, 29 | ], 30 | }, 31 | hot: true, 32 | contentBase: false, // since we use CopyWebpackPlugin. 33 | compress: true, 34 | host: HOST || config.dev.host, 35 | port: PORT || config.dev.port, 36 | open: config.dev.autoOpenBrowser, 37 | overlay: config.dev.errorOverlay 38 | ? { warnings: false, errors: true } 39 | : false, 40 | publicPath: config.dev.assetsPublicPath, 41 | proxy: config.dev.proxyTable, 42 | quiet: true, // necessary for FriendlyErrorsPlugin 43 | watchOptions: { 44 | poll: config.dev.poll, 45 | } 46 | }, 47 | plugins: [ 48 | new webpack.DefinePlugin({ 49 | 'process.env': require('../config/dev.env') 50 | }), 51 | new webpack.HotModuleReplacementPlugin(), 52 | new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. 53 | new webpack.NoEmitOnErrorsPlugin(), 54 | // https://github.com/ampedandwired/html-webpack-plugin 55 | new HtmlWebpackPlugin({ 56 | filename: 'index.html', 57 | template: 'index.html', 58 | inject: true 59 | }), 60 | // copy custom static assets 61 | new CopyWebpackPlugin([ 62 | { 63 | from: path.resolve(__dirname, '../static'), 64 | to: config.dev.assetsSubDirectory, 65 | ignore: ['.*'] 66 | } 67 | ]) 68 | ] 69 | }) 70 | 71 | module.exports = new Promise((resolve, reject) => { 72 | portfinder.basePort = process.env.PORT || config.dev.port 73 | portfinder.getPort((err, port) => { 74 | if (err) { 75 | reject(err) 76 | } else { 77 | // publish the new Port, necessary for e2e tests 78 | process.env.PORT = port 79 | // add port to devServer config 80 | devWebpackConfig.devServer.port = port 81 | 82 | // Add FriendlyErrorsPlugin 83 | devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ 84 | compilationSuccessInfo: { 85 | messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], 86 | }, 87 | onErrors: config.dev.notifyOnErrors 88 | ? utils.createNotifierCallback() 89 | : undefined 90 | })) 91 | 92 | resolve(devWebpackConfig) 93 | } 94 | }) 95 | }) 96 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const webpack = require('webpack') 5 | const config = require('../config') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | // const ExtractTextPlugin = require('extract-text-webpack-plugin') 11 | const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 12 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin') 13 | 14 | const env = require('../config/prod.env') 15 | 16 | const webpackConfig = merge(baseWebpackConfig, { 17 | module: { 18 | rules: utils.styleLoaders({ 19 | sourceMap: config.build.productionSourceMap, 20 | extract: false, 21 | usePostCSS: true 22 | }) 23 | }, 24 | devtool: config.build.productionSourceMap ? config.build.devtool : false, 25 | output: { 26 | path: config.build.assetsRoot, 27 | filename: utils.assetsPath('[name].js') 28 | // chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 29 | }, 30 | plugins: [ 31 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 32 | new webpack.DefinePlugin({ 33 | 'process.env': env 34 | }), 35 | new UglifyJsPlugin({ 36 | uglifyOptions: { 37 | compress: { 38 | warnings: false 39 | } 40 | }, 41 | sourceMap: config.build.productionSourceMap, 42 | parallel: true 43 | }), 44 | // extract css into its own file 45 | // new ExtractTextPlugin({ 46 | // filename: utils.assetsPath('[name].css'), 47 | // // Setting the following option to `false` will not extract CSS from codesplit chunks. 48 | // // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. 49 | // // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, 50 | // // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 51 | // allChunks: true, 52 | // }), 53 | // Compress extracted CSS. We are using this plugin so that possible 54 | // duplicated CSS from different components can be deduped. 55 | new OptimizeCSSPlugin({ 56 | cssProcessorOptions: config.build.productionSourceMap 57 | ? { safe: true, map: { inline: false } } 58 | : { safe: true } 59 | }), 60 | // generate dist index.html with correct asset hash for caching. 61 | // you can customize output by editing /index.html 62 | // see https://github.com/ampedandwired/html-webpack-plugin 63 | // new HtmlWebpackPlugin({ 64 | // filename: config.build.index, 65 | // template: 'index.html', 66 | // inject: true, 67 | // minify: { 68 | // removeComments: true, 69 | // collapseWhitespace: true, 70 | // removeAttributeQuotes: true 71 | // // more options: 72 | // // https://github.com/kangax/html-minifier#options-quick-reference 73 | // }, 74 | // // necessary to consistently work with multiple chunks via CommonsChunkPlugin 75 | // chunksSortMode: 'dependency' 76 | // }), 77 | // keep module.id stable when vendor modules does not change 78 | new webpack.HashedModuleIdsPlugin(), 79 | // enable scope hoisting 80 | new webpack.optimize.ModuleConcatenationPlugin(), 81 | // split vendor js into its own file 82 | // new webpack.optimize.CommonsChunkPlugin({ 83 | // name: 'vendor', 84 | // minChunks (module) { 85 | // // any required modules inside node_modules are extracted to vendor 86 | // return ( 87 | // module.resource && 88 | // /\.js$/.test(module.resource) && 89 | // module.resource.indexOf( 90 | // path.join(__dirname, '../node_modules') 91 | // ) === 0 92 | // ) 93 | // } 94 | // }), 95 | // extract webpack runtime and module manifest to its own file in order to 96 | // prevent vendor hash from being updated whenever app bundle is updated 97 | // new webpack.optimize.CommonsChunkPlugin({ 98 | // name: 'manifest', 99 | // minChunks: Infinity 100 | // }), 101 | // This instance extracts shared chunks from code splitted chunks and bundles them 102 | // in a separate chunk, similar to the vendor chunk 103 | // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk 104 | // new webpack.optimize.CommonsChunkPlugin({ 105 | // name: 'app', 106 | // async: 'vendor-async', 107 | // children: true, 108 | // minChunks: 3 109 | // }), 110 | 111 | // copy custom static assets 112 | new CopyWebpackPlugin([ 113 | { 114 | from: path.resolve(__dirname, '../static'), 115 | to: config.build.assetsSubDirectory, 116 | ignore: ['.*'] 117 | } 118 | ]) 119 | ] 120 | }) 121 | 122 | if (config.build.productionGzip) { 123 | const CompressionWebpackPlugin = require('compression-webpack-plugin') 124 | 125 | webpackConfig.plugins.push( 126 | new CompressionWebpackPlugin({ 127 | asset: '[path].gz[query]', 128 | algorithm: 'gzip', 129 | test: new RegExp( 130 | '\\.(' + 131 | config.build.productionGzipExtensions.join('|') + 132 | ')$' 133 | ), 134 | threshold: 10240, 135 | minRatio: 0.8 136 | }) 137 | ) 138 | } 139 | 140 | if (config.build.bundleAnalyzerReport) { 141 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 142 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 143 | } 144 | 145 | module.exports = webpackConfig 146 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.3.1 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | 10 | // Paths 11 | assetsSubDirectory: 'static', 12 | assetsPublicPath: '/', 13 | proxyTable: {}, 14 | 15 | // Various Dev Server settings 16 | host: 'localhost', // can be overwritten by process.env.HOST 17 | port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 18 | autoOpenBrowser: false, 19 | errorOverlay: true, 20 | notifyOnErrors: true, 21 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 22 | 23 | // Use Eslint Loader? 24 | // If true, your code will be linted during bundling and 25 | // linting errors and warnings will be shown in the console. 26 | useEslint: true, 27 | // If true, eslint errors and warnings will also be shown in the error overlay 28 | // in the browser. 29 | showEslintErrorsInOverlay: false, 30 | 31 | /** 32 | * Source Maps 33 | */ 34 | 35 | // https://webpack.js.org/configuration/devtool/#development 36 | devtool: 'cheap-module-eval-source-map', 37 | 38 | // If you have problems debugging vue-files in devtools, 39 | // set this to false - it *may* help 40 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 41 | cacheBusting: true, 42 | 43 | cssSourceMap: true 44 | }, 45 | 46 | build: { 47 | // Template for index.html 48 | index: path.resolve(__dirname, '../dist/index.html'), 49 | 50 | // Paths 51 | assetsRoot: path.resolve(__dirname, '../dist'), 52 | assetsSubDirectory: '', 53 | assetsPublicPath: '', 54 | 55 | /** 56 | * Source Maps 57 | */ 58 | 59 | productionSourceMap: false, 60 | // https://webpack.js.org/configuration/devtool/#production 61 | devtool: '#source-map', 62 | 63 | // Gzip off by default as many popular static hosts such as 64 | // Surge or Netlify already gzip all static assets for you. 65 | // Before setting to `true`, make sure to: 66 | // npm install --save-dev compression-webpack-plugin 67 | productionGzip: false, 68 | productionGzipExtensions: ['js', 'css'], 69 | 70 | // Run the build command with an extra argument to 71 | // View the bundle analyzer report after build finishes: 72 | // `npm run build --report` 73 | // Set to `true` or `false` to always turn it on or off 74 | bundleAnalyzerReport: process.env.npm_config_report 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /dist/vue-3d-menu.js: -------------------------------------------------------------------------------- 1 | !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Vue3dMenu=e():t.Vue3dMenu=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="37GF")}({"+E39":function(t,e,n){t.exports=!n("S82l")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},"+ZMJ":function(t,e,n){var r=n("lOnJ");t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}}},"+tPU":function(t,e,n){n("xGkn");for(var r=n("7KvD"),i=n("hJx8"),o=n("/bQp"),s=n("dSzd")("toStringTag"),u="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),a=0;a3&&void 0!==arguments[3]?arguments[3]:function(){},s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){};i()(this,t),this._enable=!0,this._timeBase=+new Date,this.state=0,this.tween=u.Linear,this.deferred=new f,this._from=e,this._to=n,this._duration=r,this._stepFn=o,this._endFn=s}return s()(t,[{key:"_step",value:function(){if(this._enable){var t=+new Date-this._timeBase,e=!1;t>this._duration&&(t=this._duration,e=!0);var n=this.tween(t,this._from,this._to-this._from,this._duration);this._stepFn(n),e?(this._endFn(n),this.state=2,this.deferred.resolve(n)):setTimeout(this._step.bind(this),17)}}},{key:"start",value:function(){return this.state=1,this._step(),this}},{key:"stop",value:function(){return this.state=2,this._enable=!1,this}}]),t}(),p={name:"menu-item",props:{itemInfo:{type:Object}},data:function(){return{shadow:!1,transform:"rotateX(-180deg)"}},created:function(){var t=this;this.itemInfo.onUpdate=function(e){t.transform="rotate3d(1,0,0,"+e+"deg)",t.shadow=e<-60}}},h={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"menu-item",style:{transform:t.transform}},[n("div",{class:{"menu-item-title":!0,shadow:t.shadow},on:{click:t.itemInfo.click}},[t._v(t._s(t.itemInfo.title))]),t._v(" "),t.itemInfo.next?n("menu-item",{attrs:{itemInfo:t.itemInfo.next}}):t._e()],1)},staticRenderFns:[]};var d=n("VU/8")(p,h,!1,function(t){n("TKAl")},"data-v-1f4f6fab",null).exports,v=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};i()(this,t),this.prev=null,this.next=null,this.onUpdate=function(t){},this.open=!1,this.animate=null,this.disabled=!1,this.done=c.a.resolve(),this.title=e,this.click=n}return s()(t,[{key:"goUp",value:function(){var t=this;if(this.disabled=!1,!this.open)return this.done=c.a.resolve(),void(this.prev&&this.prev.goUp());var e=new f;this.done=e.promise;var n=!1;this.animate=new l(0,-180,300,function(e){t.onUpdate(e),e<-90&&!n&&!t.disabled&&(n=!0,t.prev&&t.prev.goUp())},function(){t.open=!1,e.resolve()}),this.animate.start()}},{key:"goDown",value:function(){var t=this;if(this.disabled=!1,this.open)return this.done=c.a.resolve(),void(this.next&&this.next.goDown());var e=new f;this.done=e.promise;var n=!1;this.animate=new l(-180,0,700,function(e){t.onUpdate(e),e>-90&&!n&&!t.disabled&&(n=!0,t.next&&t.next.goDown())},function(){t.open=!0,e.resolve()}),this.animate.tween=u.BackEaseOut,this.animate.start()}},{key:"stop",value:function(){return this.disabled=!0,this.done}}]),t}(),m=function(){function t(){i()(this,t),this.list=[]}return s()(t,[{key:"add",value:function(t){this.list.push(t)}},{key:"clear",value:function(){this.list=[]}},{key:"dequeue",value:function(){for(;this.list.length;){this.list.shift()()}}}]),t}(),x=function(){function t(e){i()(this,t),this.itemList=[],this.queue=new m,this.itemList=e}return s()(t,[{key:"goUp",value:function(){var t=this;this.attach(function(){return t.itemList[t.itemList.length-1].goUp()})}},{key:"goDown",value:function(){var t=this;this.attach(function(){return t.itemList[0].goDown()})}},{key:"attach",value:function(t){var e=this;this.queue.clear(),this.queue.add(t),c.a.all(this.itemList.map(function(t){return t.stop()})).then(function(){return e.queue.dequeue()})}}]),t}(),b={props:{title:{type:String,default:"hello menu"},items:{type:Array,required:!0}},data:function(){return{offsetY:0,rotate:null}},computed:{itemList:function(){var t=this.items.map(function(t){var e=t.title,n=t.click;return new v(e,n)});return t.reduce(function(t,e){return t&&(t.next=e),e&&(e.prev=t),e}),t}},methods:{handleMove:function(t){var e=.5*(t.offsetX-73);this.offsetY=e},handleEnter:function(){this.rotate.goDown()},handleLeave:function(){this.rotate.goUp()}},created:function(){this.rotate=new x(this.itemList)},components:{MenuItem:d}},y={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"vue-3d-menu"},[n("div",{staticClass:"menu-wrap",style:{transform:"rotate3d(0,1,0,"+t.offsetY+"deg)"},on:{mouseenter:t.handleEnter,mouseleave:t.handleLeave,mousemove:t.handleMove}},[n("div",{staticClass:"vue-3d-menu-title"},[t._v(t._s(t.title))]),t._v(" "),n("menu-item",{attrs:{itemInfo:t.itemList[0]}})],1)])},staticRenderFns:[]};var g=n("VU/8")(b,y,!1,function(t){n("pdJX")},"data-v-209ce192",null).exports;g.install=function(t){t.component("vue-3d-menu",g)};e.default=g},"3Eo+":function(t,e){var n=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+r).toString(36))}},"3fs2":function(t,e,n){var r=n("RY/4"),i=n("dSzd")("iterator"),o=n("/bQp");t.exports=n("FeBl").getIteratorMethod=function(t){if(void 0!=t)return t[i]||t["@@iterator"]||o[r(t)]}},"4mcu":function(t,e){t.exports=function(){}},"52gC":function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},"77Pl":function(t,e,n){var r=n("EqjI");t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},"7KvD":function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},"82Mu":function(t,e,n){var r=n("7KvD"),i=n("L42u").set,o=r.MutationObserver||r.WebKitMutationObserver,s=r.process,u=r.Promise,a="process"==n("R9M2")(s);t.exports=function(){var t,e,n,c=function(){var r,i;for(a&&(r=s.domain)&&r.exit();t;){i=t.fn,t=t.next;try{i()}catch(r){throw t?n():e=void 0,r}}e=void 0,r&&r.enter()};if(a)n=function(){s.nextTick(c)};else if(!o||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var f=u.resolve();n=function(){f.then(c)}}else n=function(){i.call(r,c)};else{var l=!0,p=document.createTextNode("");new o(c).observe(p,{characterData:!0}),n=function(){p.data=l=!l}}return function(r){var i={fn:r,next:void 0};e&&(e.next=i),t||(t=i,n()),e=i}}},"880/":function(t,e,n){t.exports=n("hJx8")},"94VQ":function(t,e,n){"use strict";var r=n("Yobk"),i=n("X8DO"),o=n("e6n0"),s={};n("hJx8")(s,n("dSzd")("iterator"),function(){return this}),t.exports=function(t,e,n){t.prototype=r(s,{next:i(1,n)}),o(t,e+" Iterator")}},"9bBU":function(t,e,n){n("mClu");var r=n("FeBl").Object;t.exports=function(t,e,n){return r.defineProperty(t,e,n)}},"9ejn":function(t,e){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJIAAAA2CAYAAAAs9sB2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QkVCNDJEMzMxNjJGMTFFM0I4QjNGOTE2MTdBNDEzM0IiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QkVCNDJEMzQxNjJGMTFFM0I4QjNGOTE2MTdBNDEzM0IiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpCRUI0MkQzMTE2MkYxMUUzQjhCM0Y5MTYxN0E0MTMzQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpCRUI0MkQzMjE2MkYxMUUzQjhCM0Y5MTYxN0E0MTMzQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PmoZZUgAAAlmSURBVHja7Fx7jFxV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"},C4MV:function(t,e,n){t.exports={default:n("9bBU"),__esModule:!0}},CXw9:function(t,e,n){"use strict";var r,i,o,s,u=n("O4g8"),a=n("7KvD"),c=n("+ZMJ"),f=n("RY/4"),l=n("kM2E"),p=n("EqjI"),h=n("lOnJ"),d=n("2KxR"),v=n("NWt+"),m=n("t8x9"),x=n("L42u").set,b=n("82Mu")(),y=n("qARP"),g=n("dNDb"),w=n("fJUb"),M=a.TypeError,S=a.process,j=a.Promise,k="process"==f(S),_=function(){},E=i=y.f,R=!!function(){try{var t=j.resolve(1),e=(t.constructor={})[n("dSzd")("species")]=function(t){t(_,_)};return(k||"function"==typeof PromiseRejectionEvent)&&t.then(_)instanceof e}catch(t){}}(),L=function(t){var e;return!(!p(t)||"function"!=typeof(e=t.then))&&e},A=function(t,e){if(!t._n){t._n=!0;var n=t._c;b(function(){for(var r=t._v,i=1==t._s,o=0,s=function(e){var n,o,s,u=i?e.ok:e.fail,a=e.resolve,c=e.reject,f=e.domain;try{u?(i||(2==t._h&&C(t),t._h=1),!0===u?n=r:(f&&f.enter(),n=u(r),f&&(f.exit(),s=!0)),n===e.promise?c(M("Promise-chain cycle")):(o=L(n))?o.call(n,a,c):a(n)):c(r)}catch(t){f&&!s&&f.exit(),c(t)}};n.length>o;)s(n[o++]);t._c=[],t._n=!1,e&&!t._h&&O(t)})}},O=function(t){x.call(a,function(){var e,n,r,i=t._v,o=P(t);if(o&&(e=g(function(){k?S.emit("unhandledRejection",i,t):(n=a.onunhandledrejection)?n({promise:t,reason:i}):(r=a.console)&&r.error&&r.error("Unhandled promise rejection",i)}),t._h=k||P(t)?2:1),t._a=void 0,o&&e.e)throw e.v})},P=function(t){return 1!==t._h&&0===(t._a||t._c).length},C=function(t){x.call(a,function(){var e;k?S.emit("rejectionHandled",t):(e=a.onrejectionhandled)&&e({promise:t,reason:t._v})})},G=function(t){var e=this;e._d||(e._d=!0,(e=e._w||e)._v=t,e._s=2,e._a||(e._a=e._c.slice()),A(e,!0))},I=function(t){var e,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===t)throw M("Promise can't be resolved itself");(e=L(t))?b(function(){var r={_w:n,_d:!1};try{e.call(t,c(I,r,1),c(G,r,1))}catch(t){G.call(r,t)}}):(n._v=t,n._s=1,A(n,!1))}catch(t){G.call({_w:n,_d:!1},t)}}};R||(j=function(t){d(this,j,"Promise","_h"),h(t),r.call(this);try{t(c(I,this,1),c(G,this,1))}catch(t){G.call(this,t)}},(r=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=n("xH/j")(j.prototype,{then:function(t,e){var n=E(m(this,j));return n.ok="function"!=typeof t||t,n.fail="function"==typeof e&&e,n.domain=k?S.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&A(this,!1),n.promise},catch:function(t){return this.then(void 0,t)}}),o=function(){var t=new r;this.promise=t,this.resolve=c(I,t,1),this.reject=c(G,t,1)},y.f=E=function(t){return t===j||t===s?new o(t):i(t)}),l(l.G+l.W+l.F*!R,{Promise:j}),n("e6n0")(j,"Promise"),n("bRrM")("Promise"),s=n("FeBl").Promise,l(l.S+l.F*!R,"Promise",{reject:function(t){var e=E(this);return(0,e.reject)(t),e.promise}}),l(l.S+l.F*(u||!R),"Promise",{resolve:function(t){return w(u&&this===s?j:this,t)}}),l(l.S+l.F*!(R&&n("dY0y")(function(t){j.all(t).catch(_)})),"Promise",{all:function(t){var e=this,n=E(e),r=n.resolve,i=n.reject,o=g(function(){var n=[],o=0,s=1;v(t,!1,function(t){var u=o++,a=!1;n.push(void 0),s++,e.resolve(t).then(function(t){a||(a=!0,n[u]=t,--s||r(n))},i)}),--s||r(n)});return o.e&&i(o.v),n.promise},race:function(t){var e=this,n=E(e),r=n.reject,i=g(function(){v(t,!1,function(t){e.resolve(t).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}})},D2L2:function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},EGZi:function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},EqBC:function(t,e,n){"use strict";var r=n("kM2E"),i=n("FeBl"),o=n("7KvD"),s=n("t8x9"),u=n("fJUb");r(r.P+r.R,"Promise",{finally:function(t){var e=s(this,i.Promise||o.Promise),n="function"==typeof t;return this.then(n?function(n){return u(e,t()).then(function(){return n})}:t,n?function(n){return u(e,t()).then(function(){throw n})}:t)}})},EqjI:function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},"FZ+f":function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",r=t[3];if(!r)return n;if(e&&"function"==typeof btoa){var i=(s=r,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(s))))+" */"),o=r.sources.map(function(t){return"/*# sourceURL="+r.sourceRoot+t+" */"});return[n].concat(o).concat([i]).join("\n")}var s;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},i=0;ia;)r(u,n=e[a++])&&(~o(c,n)||c.push(n));return c}},L42u:function(t,e,n){var r,i,o,s=n("+ZMJ"),u=n("knuC"),a=n("RPLV"),c=n("ON07"),f=n("7KvD"),l=f.process,p=f.setImmediate,h=f.clearImmediate,d=f.MessageChannel,v=f.Dispatch,m=0,x={},b=function(){var t=+this;if(x.hasOwnProperty(t)){var e=x[t];delete x[t],e()}},y=function(t){b.call(t.data)};p&&h||(p=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return x[++m]=function(){u("function"==typeof t?t:Function(t),e)},r(m),m},h=function(t){delete x[t]},"process"==n("R9M2")(l)?r=function(t){l.nextTick(s(b,t,1))}:v&&v.now?r=function(t){v.now(s(b,t,1))}:d?(o=(i=new d).port2,i.port1.onmessage=y,r=s(o.postMessage,o,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(r=function(t){f.postMessage(t+"","*")},f.addEventListener("message",y,!1)):r="onreadystatechange"in c("script")?function(t){a.appendChild(c("script")).onreadystatechange=function(){a.removeChild(this),b.call(t)}}:function(t){setTimeout(s(b,t,1),0)}),t.exports={set:p,clear:h}},M6a0:function(t,e){},MU5D:function(t,e,n){var r=n("R9M2");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},Mhyx:function(t,e,n){var r=n("/bQp"),i=n("dSzd")("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||o[i]===t)}},MmMw:function(t,e,n){var r=n("EqjI");t.exports=function(t,e){if(!r(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!r(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},"NWt+":function(t,e,n){var r=n("+ZMJ"),i=n("msXi"),o=n("Mhyx"),s=n("77Pl"),u=n("QRG4"),a=n("3fs2"),c={},f={};(e=t.exports=function(t,e,n,l,p){var h,d,v,m,x=p?function(){return t}:a(t),b=r(n,l,e?2:1),y=0;if("function"!=typeof x)throw TypeError(t+" is not iterable!");if(o(x)){for(h=u(t.length);h>y;y++)if((m=e?b(s(d=t[y])[0],d[1]):b(t[y]))===c||m===f)return m}else for(v=x.call(t);!(d=v.next()).done;)if((m=i(v,b,d.value,e))===c||m===f)return m}).BREAK=c,e.RETURN=f},O4g8:function(t,e){t.exports=!0},ON07:function(t,e,n){var r=n("EqjI"),i=n("7KvD").document,o=r(i)&&r(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},PzxK:function(t,e,n){var r=n("D2L2"),i=n("sB3e"),o=n("ax3d")("IE_PROTO"),s=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),r(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?s:null}},QRG4:function(t,e,n){var r=n("UuGF"),i=Math.min;t.exports=function(t){return t>0?i(r(t),9007199254740991):0}},R9M2:function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},RPLV:function(t,e,n){var r=n("7KvD").document;t.exports=r&&r.documentElement},"RY/4":function(t,e,n){var r=n("R9M2"),i=n("dSzd")("toStringTag"),o="Arguments"==r(function(){return arguments}());t.exports=function(t){var e,n,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),i))?n:o?r(e):"Object"==(s=r(e))&&"function"==typeof e.callee?"Arguments":s}},S82l:function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},SfB7:function(t,e,n){t.exports=!n("+E39")&&!n("S82l")(function(){return 7!=Object.defineProperty(n("ON07")("div"),"a",{get:function(){return 7}}).a})},TKAl:function(t,e,n){var r=n("gpEg");"string"==typeof r&&(r=[[t.i,r,""]]),r.locals&&(t.exports=r.locals);n("rjj0")("1dd0b9a5",r,!0,{})},TcQ7:function(t,e,n){var r=n("MU5D"),i=n("52gC");t.exports=function(t){return r(i(t))}},U5ju:function(t,e,n){n("M6a0"),n("zQR9"),n("+tPU"),n("CXw9"),n("EqBC"),n("jKW+"),t.exports=n("FeBl").Promise},UuGF:function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},"VU/8":function(t,e){t.exports=function(t,e,n,r,i,o){var s,u=t=t||{},a=typeof t.default;"object"!==a&&"function"!==a||(s=t,u=t.default);var c,f="function"==typeof u?u.options:u;if(e&&(f.render=e.render,f.staticRenderFns=e.staticRenderFns,f._compiled=!0),n&&(f.functional=!0),i&&(f._scopeId=i),o?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},f._ssrRegister=c):r&&(c=r),c){var l=f.functional,p=l?f.render:f.beforeCreate;l?(f._injectStyles=c,f.render=function(t,e){return c.call(e),p(t,e)}):f.beforeCreate=p?[].concat(p,c):[c]}return{esModule:s,exports:u,options:f}}},X8DO:function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},Yobk:function(t,e,n){var r=n("77Pl"),i=n("qio6"),o=n("xnc9"),s=n("ax3d")("IE_PROTO"),u=function(){},a=function(){var t,e=n("ON07")("iframe"),r=o.length;for(e.style.display="none",n("RPLV").appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write(" 29 | 30 | 50 | -------------------------------------------------------------------------------- /src/Vue3dMenu/MenuItem.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 44 | 45 | 83 | 84 | -------------------------------------------------------------------------------- /src/Vue3dMenu/Vue3dMenu.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 69 | 70 | 99 | -------------------------------------------------------------------------------- /src/Vue3dMenu/assets/topMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shalldie/vue-3d-menu/c128572f70a70176a966e6fe9c807aa78340c915/src/Vue3dMenu/assets/topMenu.png -------------------------------------------------------------------------------- /src/Vue3dMenu/index.js: -------------------------------------------------------------------------------- 1 | import Vue3dMenu from './Vue3dMenu'; 2 | 3 | Vue3dMenu.install = function (Vue) { 4 | Vue.component('vue-3d-menu', Vue3dMenu); 5 | }; 6 | 7 | export default Vue3dMenu; 8 | -------------------------------------------------------------------------------- /src/Vue3dMenu/lib/Animate.js: -------------------------------------------------------------------------------- 1 | import Tween from './Tween'; 2 | import Deferred from "./Deferred"; 3 | 4 | /** 5 | * 缓动动画类 6 | * 7 | * @export 8 | * @class Animate 9 | */ 10 | export default class Animate { 11 | //#region private fields 私有字段 12 | 13 | /** 14 | * 是否可用 15 | * 16 | * @memberof Animate 17 | */ 18 | _enable = true; 19 | 20 | /** 21 | * 起始时间 22 | * 23 | * @memberof Animate 24 | */ 25 | _timeBase = +new Date; 26 | 27 | /** 28 | * 起始值 29 | * 30 | * @memberof Animate 31 | */ 32 | _from; 33 | 34 | /** 35 | * 目标值 36 | * 37 | * @memberof Animate 38 | */ 39 | _to; 40 | 41 | /** 42 | * 持续时间 43 | * 44 | * @memberof Animate 45 | */ 46 | _duration; 47 | 48 | //#endregion 49 | 50 | /** 51 | * Creates an instance of Animate. 52 | * @param {number} from 起始值 53 | * @param {number} to 目标值 54 | * @param {number} duration 持续时间 55 | * @param {(num:number)=>void} stepFn 每一步的回调 56 | * @param {(num:number)=>void} endFn 结束的回调 57 | * @memberof Animate 58 | */ 59 | constructor(from, to, duration, stepFn = function () { }, endFn = function () { }) { 60 | this._from = from; 61 | this._to = to; 62 | this._duration = duration; 63 | this._stepFn = stepFn; 64 | this._endFn = endFn; 65 | } 66 | 67 | //#region private methods 私有方法 68 | 69 | /** 70 | * 每一步的回调 71 | * 72 | * @memberof Animate 73 | */ 74 | _stepFn; 75 | 76 | /** 77 | * 结束的回调 78 | * 79 | * @memberof Animate 80 | */ 81 | _endFn; 82 | 83 | /** 84 | * 每一步的动作 85 | * 86 | * @returns 87 | * @memberof Animate 88 | */ 89 | _step() { 90 | // 如果被禁用,返回 91 | if (!this._enable) { 92 | return; 93 | } 94 | 95 | let t = +new Date - this._timeBase; // 当前步长 96 | let ifEnd = false; // 是否到最后一步 97 | 98 | //如果最后一步 99 | if (t > this._duration) { 100 | t = this._duration; 101 | ifEnd = true; 102 | } 103 | 104 | // 该步的结果 105 | let result = this.tween(t, this._from, this._to - this._from, this._duration); 106 | 107 | this._stepFn(result); 108 | 109 | if (ifEnd) { // 结束则额外回调 110 | this._endFn(result); 111 | this.state = 2; 112 | this.deferred.resolve(result); 113 | } 114 | else { // 否则递归 115 | setTimeout(this._step.bind(this), 17); 116 | } 117 | } 118 | 119 | //#endregion 120 | 121 | /** 122 | * 动画状态 0-waiting 1-pending 2-done/disabled 123 | * 124 | * @memberof Animate 125 | */ 126 | state = 0; 127 | 128 | /** 129 | * 缓动公式 {Tween.Linear|Tween.ElasticEaseOut} 130 | * 131 | * @memberof Animate 132 | */ 133 | tween = Tween.Linear; 134 | 135 | /** 136 | * 当前动画进度的 Deferred 对象 137 | * 138 | * @memberof Animate 139 | */ 140 | deferred = new Deferred(); 141 | 142 | //#region public methods 公共方法 143 | 144 | /** 145 | * 开始动画 146 | * 147 | * @returns 148 | * @memberof Animate 149 | */ 150 | start() { 151 | this.state = 1; 152 | this._step(); 153 | return this; 154 | } 155 | 156 | /** 157 | * 禁用动画 158 | * 159 | * @returns 160 | * @memberof Animate 161 | */ 162 | stop() { 163 | this.state = 2; 164 | this._enable = false; 165 | return this; 166 | } 167 | 168 | //#endregion 169 | } 170 | -------------------------------------------------------------------------------- /src/Vue3dMenu/lib/Deferred.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Deferred ,对 Promise 对一次封装 3 | * 4 | * @export 5 | * @class Deferred 6 | */ 7 | export default class Deferred { 8 | 9 | constructor() { 10 | var pro = new Promise((resolve, reject) => { 11 | this.resolve = resolve; 12 | this.reject = reject; 13 | }); 14 | // 提供 then,catch 2个接口去绑定方法 15 | this.then = pro.then.bind(pro); 16 | this.catch = pro.catch.bind(pro); 17 | // 提供 promise 属性,暴露原始 promise 对象 18 | this.promise = pro; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/Vue3dMenu/lib/ItemInfo.js: -------------------------------------------------------------------------------- 1 | import Deferred from "./Deferred"; 2 | import Animate from "./Animate"; 3 | import Tween from './Tween'; 4 | 5 | const upDuration = 300; 6 | const upInvokeNum = -90; 7 | const downDuration = 700; 8 | const downInvokeNum = -90; 9 | 10 | /** 11 | * 节点信息 12 | * 13 | * @export 14 | * @class ItemInfo 15 | */ 16 | export default class ItemInfo { 17 | 18 | /** 19 | * Creates an instance of ItemInfo. 20 | * @param {any} title 显示的文字 21 | * @param {any} [click=function () { }] 点击执行到回调函数 22 | * @memberof ItemInfo 23 | */ 24 | constructor(title, click = function () { }) { 25 | this.title = title; 26 | this.click = click; 27 | } 28 | 29 | /** 30 | * 显示的文字 31 | * 32 | * @type {string} 33 | * @memberof ItemInfo 34 | */ 35 | title; 36 | 37 | /** 38 | * 点击执行的回调函数 39 | * 40 | * @type {Function} 41 | * @memberof ItemInfo 42 | */ 43 | click; 44 | 45 | /** 46 | * 上一个节点 47 | * 48 | * @type {ItemInfo} 49 | * @memberof ItemInfo 50 | */ 51 | prev = null; 52 | 53 | /** 54 | * 下一个节点 55 | * 56 | * @type {ItemInfo} 57 | * @memberof ItemInfo 58 | */ 59 | next = null; 60 | 61 | /** 62 | * 数值更新的回调 63 | * 64 | * @memberof ItemInfo 65 | */ 66 | onUpdate = function (num) { }; 67 | 68 | /** 69 | * 是否打开 70 | * 71 | * @type {number} 72 | * @memberof ItemInfo 73 | */ 74 | open = false; 75 | 76 | /** 77 | * 动画对象 78 | * 79 | * @type {Animate} 80 | * @memberof ItemInfo 81 | */ 82 | animate = null; 83 | 84 | /** 85 | * 是否禁用 86 | * 87 | * @memberof ItemInfo 88 | */ 89 | disabled = false; 90 | 91 | /** 92 | * 已完成状态 93 | * 94 | * @memberof ItemInfo 95 | */ 96 | done = Promise.resolve(); 97 | 98 | /** 99 | * 向上翻滚 100 | * 101 | * @memberof ItemInfo 102 | */ 103 | goUp() { 104 | this.disabled = false; 105 | if (!this.open) { 106 | this.done = Promise.resolve(); 107 | this.prev && this.prev.goUp(); 108 | return; 109 | } 110 | let dfd = new Deferred(); 111 | this.done = dfd.promise; 112 | let hasInvoked = false; 113 | this.animate = new Animate(0, -180, upDuration, 114 | num => { 115 | this.onUpdate(num); 116 | if (num < upInvokeNum && !hasInvoked && !this.disabled) { 117 | hasInvoked = true; 118 | this.prev && this.prev.goUp(); 119 | } 120 | }, 121 | () => { 122 | this.open = false; 123 | dfd.resolve(); 124 | }); 125 | this.animate.start(); 126 | } 127 | 128 | goDown() { 129 | this.disabled = false; 130 | if (this.open) { 131 | this.done = Promise.resolve(); 132 | this.next && this.next.goDown(); 133 | return; 134 | } 135 | let dfd = new Deferred(); 136 | this.done = dfd.promise; 137 | let hasInvoked = false; 138 | this.animate = new Animate(-180, 0, downDuration, 139 | num => { 140 | this.onUpdate(num); 141 | if (num > downInvokeNum && !hasInvoked && !this.disabled) { 142 | hasInvoked = true; 143 | this.next && this.next.goDown(); 144 | } 145 | }, 146 | () => { 147 | this.open = true; 148 | dfd.resolve(); 149 | }); 150 | this.animate.tween = Tween.BackEaseOut; 151 | this.animate.start(); 152 | } 153 | 154 | stop() { 155 | this.disabled = true; 156 | return this.done; 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /src/Vue3dMenu/lib/Queue.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 回调队列类 3 | * 4 | * @export 5 | * @class Queue 6 | */ 7 | export default class Queue { 8 | 9 | /** 10 | * 回调队列 11 | * 12 | * @type {Array} 13 | * @memberof Callback 14 | */ 15 | list = []; 16 | 17 | /** 18 | * 添加回调 19 | * 20 | * @param {Function} fn 21 | * @memberof Callback 22 | */ 23 | add(fn) { 24 | this.list.push(fn); 25 | } 26 | 27 | /** 28 | * 清空队列 29 | * 30 | * @memberof Callback 31 | */ 32 | clear() { 33 | this.list = []; 34 | } 35 | 36 | /** 37 | * 依次出列 38 | * 39 | * @memberof Callback 40 | */ 41 | dequeue() { 42 | while (this.list.length) { 43 | let item = this.list.shift(); 44 | item(); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/Vue3dMenu/lib/Rotate.js: -------------------------------------------------------------------------------- 1 | import Animate from "./Animate"; 2 | import Tween from './Tween'; 3 | import Deferred from './Deferred'; 4 | import ItemInfo from './ItemInfo'; 5 | import Queue from './Queue'; 6 | 7 | /** 8 | * 翻转逻辑类 9 | * 10 | * @export 11 | * @class Rotate 12 | */ 13 | export default class Rotate { 14 | 15 | /** 16 | * 节点集合 17 | * @type {Array} 18 | * @memberof Rotate 19 | */ 20 | itemList = []; 21 | 22 | 23 | /** 24 | * 下一步操作的队列 25 | * 26 | * @memberof Rotate 27 | */ 28 | queue = new Queue(); 29 | 30 | /** 31 | * Creates an instance of Rotate. 32 | * @param {Array} itemList 33 | * @memberof Rotate 34 | */ 35 | constructor(itemList) { 36 | this.itemList = itemList; 37 | } 38 | 39 | /** 40 | * 上卷 41 | * 42 | * @memberof Rotate 43 | */ 44 | goUp() { 45 | this.attach(() => this.itemList[this.itemList.length - 1].goUp()); 46 | } 47 | 48 | /** 49 | * 下卷 50 | * 51 | * @memberof Rotate 52 | */ 53 | goDown() { 54 | this.attach(() => this.itemList[0].goDown()); 55 | } 56 | 57 | /** 58 | * 向队列添加某个操作,覆盖之前的行为 59 | * 60 | * @param {Function} fn 61 | * @memberof Rotate 62 | */ 63 | attach(fn) { 64 | this.queue.clear(); 65 | this.queue.add(fn); 66 | Promise.all(this.itemList.map(item => item.stop())) 67 | .then(() => this.queue.dequeue()); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/Vue3dMenu/lib/Tween.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Tween 缓动函数 3 | */ 4 | export default { 5 | /** 6 | * 无效果 7 | */ 8 | Linear: function (t, b, c, d) { return c * t / d + b; }, 9 | /** 10 | * 超过范围的三次方缓动((s+1)*t^3 - s*t^2) 11 | * 12 | * @param {any} t 当前步长 13 | * @param {any} b 初始值 14 | * @param {any} c 变化量 15 | * @param {any} d 总步长 16 | * @param {any} s 可选。这里不输入 17 | * @returns {number} 18 | */ 19 | BackEaseOut: function (t, b, c, d, s) { 20 | if (s == undefined) s = 1.70158; 21 | return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import App from './App' 5 | 6 | Vue.config.productionTip = false 7 | 8 | import Vue3dMenu from './Vue3dMenu'; 9 | Vue.use(Vue3dMenu); 10 | 11 | /* eslint-disable no-new */ 12 | new Vue({ 13 | el: '#app', 14 | components: { App }, 15 | template: '' 16 | }) 17 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shalldie/vue-3d-menu/c128572f70a70176a966e6fe9c807aa78340c915/static/.gitkeep --------------------------------------------------------------------------------