├── example ├── static │ └── .gitkeep ├── .eslintignore ├── config │ ├── prod.env.js │ ├── dev.env.js │ └── index.js ├── .gitignore ├── src │ ├── assets │ │ ├── image │ │ │ └── phone_bg.png │ │ └── css │ │ │ ├── base.css │ │ │ ├── layout.css │ │ │ ├── _marked.css │ │ │ └── normalize.css │ ├── pages │ │ ├── mobile-page.vue │ │ └── home.vue │ ├── App.vue │ ├── route │ │ └── index.js │ ├── main.js │ └── components │ │ ├── mark.vue │ │ └── phone.vue ├── .editorconfig ├── .postcssrc.js ├── build │ ├── dev-client.js │ ├── vue-loader.conf.js │ ├── build.js │ ├── webpack.dev.conf.js │ ├── check-versions.js │ ├── webpack.base.conf.js │ ├── utils.js │ ├── dev-server.js │ └── webpack.prod.conf.js ├── .babelrc ├── index.html ├── README.md ├── .eslintrc.js └── package.json ├── .npmignore ├── .gitignore ├── package.json ├── vue-fullpage.css ├── README_CN.md ├── README.md ├── doc ├── api_cn.md └── api.md └── index.js /example/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | example/ 2 | doc/ 3 | todo.md 4 | -------------------------------------------------------------------------------- /example/.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /example/config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | -------------------------------------------------------------------------------- /example/src/assets/image/phone_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taomas/vue-fullpage/HEAD/example/src/assets/image/phone_bg.png -------------------------------------------------------------------------------- /example/config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /example/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /example/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | // to edit target browsers: use "browserlist" field in package.json 6 | "autoprefixer": {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /example/src/assets/css/base.css: -------------------------------------------------------------------------------- 1 | @import 'layout.css'; 2 | @import 'normalize.css'; 3 | @import '_marked.css'; 4 | 5 | pre { 6 | padding: 10px 10px 10px 20px; 7 | background: hsla(0,0%,100%,.05); 8 | border: 1px solid hsla(0,0%,100%,.3); 9 | overflow: scroll; 10 | } 11 | -------------------------------------------------------------------------------- /example/build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /example/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { "modules": false }], 4 | "stage-2" 5 | ], 6 | "plugins": ["transform-runtime"], 7 | "comments": false, 8 | "env": { 9 | "test": { 10 | "presets": ["env", "stage-2"], 11 | "plugins": [ "istanbul" ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | vue-fullpage-demo 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /example/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var config = require('../config') 3 | var isProduction = process.env.NODE_ENV === 'production' 4 | 5 | module.exports = { 6 | loaders: utils.cssLoaders({ 7 | sourceMap: isProduction 8 | ? config.build.productionSourceMap 9 | : config.dev.cssSourceMap, 10 | extract: isProduction 11 | }), 12 | postcss: [require('precss')()] 13 | } 14 | -------------------------------------------------------------------------------- /example/src/pages/mobile-page.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | 16 | 17 | 26 | -------------------------------------------------------------------------------- /example/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | 16 | 31 | -------------------------------------------------------------------------------- /example/src/route/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | Vue.use(VueRouter) 5 | 6 | import Home from '../pages/home.vue' 7 | import Mobile from '../pages/mobile-page.vue' 8 | 9 | const routes = [ 10 | { 11 | path: '/', 12 | name: 'home', 13 | component: Home 14 | }, 15 | { 16 | path: '/mobile', 17 | name: 'mobile', 18 | component: Mobile 19 | }, 20 | { 21 | path: '*', 22 | redirect: '/' 23 | } 24 | ] 25 | 26 | export default new VueRouter({ 27 | routes 28 | }) 29 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example1 2 | 3 | > A Vue.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | 17 | # build for production and view the bundle analyzer report 18 | npm run build --report 19 | ``` 20 | 21 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 22 | -------------------------------------------------------------------------------- /example/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import TouchEmulator from 'hammer-touchemulator/touch-emulator.js' 3 | import App from './App.vue' 4 | import 'normalize.css' 5 | import 'animate.css' 6 | import 'vue-fullpage/vue-fullpage.css' 7 | // import VueFullpage from 'vue-fullpage' 8 | // import '../../vue-fullpage.css' 9 | import VueFullpage from '../../index.js' 10 | import router from './route/index.js' 11 | 12 | Vue.use(VueFullpage) 13 | TouchEmulator() 14 | 15 | /* eslint-disable */ 16 | new Vue({ 17 | el: '#app', 18 | router, 19 | render: h => h(App) 20 | }) 21 | /* eslint-enable */ 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-fullpage", 3 | "version": "2.0.5", 4 | "description": "a single page scroll plugin for vue.js ", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/wendaosanshou/vue-fullpage.git" 12 | }, 13 | "keywords": [ 14 | "vue", 15 | "scroll", 16 | "single", 17 | "page" 18 | ], 19 | "author": "wendaosanshou", 20 | "license": "ISC", 21 | "bugs": { 22 | "url": "https://github.com/wendaosanshou/vue-fullpage/issues" 23 | }, 24 | "homepage": "https://github.com/wendaosanshou/vue-fullpage#readme" 25 | } 26 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // http://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style 13 | extends: 'standard', 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'html' 17 | ], 18 | // add your custom rules here 19 | 'rules': { 20 | 'space-before-function-paren': 0, 21 | // allow paren-less arrow functions 22 | 'arrow-parens': 0, 23 | // allow async-await 24 | 'generator-star-spacing': 0, 25 | // allow debugger during development 26 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vue-fullpage.css: -------------------------------------------------------------------------------- 1 | .fullpage-container { 2 | position: relative; 3 | width: 100%; 4 | height: 100%; 5 | overflow: hidden; 6 | } 7 | 8 | .fullpage-wp { 9 | display: flex; 10 | width: 100%; 11 | height: 100%; 12 | flex-flow: column nowrap; 13 | justify-content: flex-start; 14 | align-items: center; 15 | } 16 | 17 | .fullpage-wp.anim{ 18 | transform: translate3d(0,0,0); 19 | -webkit-transition: all 500ms ease-out 0s; 20 | transition: all 500ms ease-out 0s; 21 | } 22 | 23 | .fullpage-wp.fullpage-wp-h { 24 | display: flex; 25 | flex-flow: row nowrap; 26 | justify-content: flex-start; 27 | align-items: center; 28 | } 29 | 30 | .page { 31 | box-sizing: border-box; 32 | display: block; 33 | position: relative; 34 | width: 100%; 35 | height: 100%; 36 | flex-shrink: 0; 37 | overflow: hidden; 38 | } 39 | 40 | .animated { 41 | opacity: 1; 42 | } 43 | -------------------------------------------------------------------------------- /example/src/assets/css/layout.css: -------------------------------------------------------------------------------- 1 | .ly-col-flex { 2 | display: flex; 3 | flex-direction: column; 4 | flex-wrap: wrap; 5 | &:before, 6 | &:after { 7 | display: flex; 8 | } 9 | } 10 | 11 | .ly-row-flex { 12 | display: flex; 13 | flex-direction: row; 14 | flex-wrap: wrap; 15 | &:before, 16 | &:after { 17 | display: flex; 18 | } 19 | } 20 | 21 | .flex-start { 22 | justify-content: flex-start; 23 | } 24 | 25 | .flex-center { 26 | justify-content: center; 27 | } 28 | 29 | .flex-end { 30 | justify-content: flex-end; 31 | } 32 | 33 | .flex-space-between { 34 | justify-content: space-between; 35 | } 36 | 37 | .flex-space-around { 38 | justify-content: space-around; 39 | } 40 | 41 | .flex-top { 42 | align-items: flex-start; 43 | } 44 | 45 | .flex-middle { 46 | align-items: center; 47 | } 48 | 49 | .flex-bottom { 50 | align-items: flex-end; 51 | } 52 | -------------------------------------------------------------------------------- /example/build/build.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | var ora = require('ora') 6 | var rm = require('rimraf') 7 | var path = require('path') 8 | var chalk = require('chalk') 9 | var webpack = require('webpack') 10 | var config = require('../config') 11 | var webpackConfig = require('./webpack.prod.conf') 12 | 13 | var spinner = ora('building for production...') 14 | spinner.start() 15 | 16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 17 | if (err) throw err 18 | webpack(webpackConfig, function (err, stats) { 19 | spinner.stop() 20 | if (err) throw err 21 | process.stdout.write(stats.toString({ 22 | colors: true, 23 | modules: false, 24 | children: false, 25 | chunks: false, 26 | chunkModules: false 27 | }) + '\n\n') 28 | 29 | console.log(chalk.cyan(' Build complete.\n')) 30 | console.log(chalk.yellow( 31 | ' Tip: built files are meant to be served over an HTTP server.\n' + 32 | ' Opening index.html over file:// won\'t work.\n' 33 | )) 34 | }) 35 | }) 36 | -------------------------------------------------------------------------------- /example/src/assets/css/_marked.css: -------------------------------------------------------------------------------- 1 | /** 2 | * GitHub Gist Theme 3 | * Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro 4 | */ 5 | 6 | .hljs { 7 | display: block; 8 | background: white; 9 | padding: 0.5em; 10 | color: #333333; 11 | overflow-x: auto; 12 | } 13 | 14 | .hljs-comment, 15 | .hljs-meta { 16 | color: #a2fca2; 17 | } 18 | 19 | .hljs-string, 20 | .hljs-variable, 21 | .hljs-template-variable, 22 | .hljs-strong, 23 | .hljs-emphasis, 24 | .hljs-quote { 25 | color: #a2fca2; 26 | } 27 | 28 | .hljs-keyword, 29 | .hljs-selector-tag, 30 | .hljs-type { 31 | color: #fcc28c; 32 | } 33 | 34 | .hljs-literal, 35 | .hljs-symbol, 36 | .hljs-bullet, 37 | .hljs-attribute { 38 | color: #fcc28c; 39 | } 40 | 41 | .hljs-section, 42 | .hljs-name { 43 | color: #63a35c; 44 | } 45 | 46 | .hljs-tag { 47 | color: #63a35c; 48 | } 49 | 50 | .hljs-title, 51 | .hljs-attr, 52 | .hljs-selector-id, 53 | .hljs-selector-class, 54 | .hljs-selector-attr, 55 | .hljs-selector-pseudo { 56 | color: #fcc28c; 57 | } 58 | 59 | .hljs-addition { 60 | color: #55a532; 61 | background-color: #eaffea; 62 | } 63 | 64 | .hljs-deletion { 65 | color: #bd2c00; 66 | background-color: #ffecec; 67 | } 68 | 69 | .hljs-link { 70 | text-decoration: underline; 71 | } 72 | -------------------------------------------------------------------------------- /example/src/components/mark.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 49 | 50 | 57 | -------------------------------------------------------------------------------- /example/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var webpack = require('webpack') 3 | var config = require('../config') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 12 | }) 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: '#cheap-module-eval-source-map', 20 | plugins: [ 21 | new webpack.DefinePlugin({ 22 | 'process.env': config.dev.env 23 | }), 24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 25 | new webpack.HotModuleReplacementPlugin(), 26 | new webpack.NoEmitOnErrorsPlugin(), 27 | // https://github.com/ampedandwired/html-webpack-plugin 28 | new HtmlWebpackPlugin({ 29 | filename: 'index.html', 30 | template: 'index.html', 31 | inject: true 32 | }), 33 | new FriendlyErrorsPlugin() 34 | ] 35 | }) 36 | -------------------------------------------------------------------------------- /example/build/check-versions.js: -------------------------------------------------------------------------------- 1 | var chalk = require('chalk') 2 | var semver = require('semver') 3 | var packageConfig = require('../package.json') 4 | var shell = require('shelljs') 5 | function exec (cmd) { 6 | return require('child_process').execSync(cmd).toString().trim() 7 | } 8 | 9 | var versionRequirements = [ 10 | { 11 | name: 'node', 12 | currentVersion: semver.clean(process.version), 13 | versionRequirement: packageConfig.engines.node 14 | }, 15 | ] 16 | 17 | if (shell.which('npm')) { 18 | versionRequirements.push({ 19 | name: 'npm', 20 | currentVersion: exec('npm --version'), 21 | versionRequirement: packageConfig.engines.npm 22 | }) 23 | } 24 | 25 | module.exports = function () { 26 | var warnings = [] 27 | for (var i = 0; i < versionRequirements.length; i++) { 28 | var mod = versionRequirements[i] 29 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 30 | warnings.push(mod.name + ': ' + 31 | chalk.red(mod.currentVersion) + ' should be ' + 32 | chalk.green(mod.versionRequirement) 33 | ) 34 | } 35 | } 36 | 37 | if (warnings.length) { 38 | console.log('') 39 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 40 | console.log() 41 | for (var i = 0; i < warnings.length; i++) { 42 | var warning = warnings[i] 43 | console.log(' ' + warning) 44 | } 45 | console.log() 46 | process.exit(1) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /example/config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: 'http://vue.fecss.com/vue-fullpage/', 11 | productionSourceMap: true, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'], 18 | // Run the build command with an extra argument to 19 | // View the bundle analyzer report after build finishes: 20 | // `npm run build --report` 21 | // Set to `true` or `false` to always turn it on or off 22 | bundleAnalyzerReport: process.env.npm_config_report 23 | }, 24 | dev: { 25 | env: require('./dev.env'), 26 | port: 8080, 27 | autoOpenBrowser: true, 28 | assetsSubDirectory: 'static', 29 | assetsPublicPath: '/', 30 | proxyTable: {}, 31 | // CSS Sourcemaps off by default because relative paths are "buggy" 32 | // with this option, according to the CSS-Loader README 33 | // (https://github.com/webpack/css-loader#sourcemaps) 34 | // In our experience, they generally work as expected, 35 | // just be aware of this issue when enabling this option. 36 | cssSourceMap: false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var config = require('../config') 4 | var vueLoaderConfig = require('./vue-loader.conf') 5 | 6 | function resolve (dir) { 7 | return path.join(__dirname, '..', dir) 8 | } 9 | 10 | module.exports = { 11 | entry: { 12 | app: './src/main.js' 13 | }, 14 | output: { 15 | path: config.build.assetsRoot, 16 | filename: '[name].js', 17 | publicPath: process.env.NODE_ENV === 'production' 18 | ? config.build.assetsPublicPath 19 | : config.dev.assetsPublicPath 20 | }, 21 | resolve: { 22 | extensions: ['.js', '.vue', '.json'], 23 | alias: { 24 | 'vue$': 'vue/dist/vue.esm.js', 25 | '@': resolve('src') 26 | } 27 | }, 28 | module: { 29 | rules: [ 30 | { 31 | test: /\.(js|vue)$/, 32 | loader: 'eslint-loader', 33 | enforce: 'pre', 34 | include: [resolve('src'), resolve('test')], 35 | options: { 36 | formatter: require('eslint-friendly-formatter') 37 | } 38 | }, 39 | { 40 | test: /\.vue$/, 41 | loader: 'vue-loader', 42 | options: vueLoaderConfig 43 | }, 44 | { 45 | test: /\.js$/, 46 | loader: 'babel-loader', 47 | include: [resolve('src'), resolve('test')] 48 | }, 49 | { 50 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 51 | loader: 'url-loader', 52 | options: { 53 | limit: 10000, 54 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 55 | } 56 | }, 57 | { 58 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 59 | loader: 'url-loader', 60 | options: { 61 | limit: 10000, 62 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 63 | } 64 | } 65 | ] 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /example/src/components/phone.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 51 | 52 | 74 | -------------------------------------------------------------------------------- /example/build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | var assetsSubDirectory = process.env.NODE_ENV === 'production' 7 | ? config.build.assetsSubDirectory 8 | : config.dev.assetsSubDirectory 9 | return path.posix.join(assetsSubDirectory, _path) 10 | } 11 | 12 | exports.cssLoaders = function (options) { 13 | options = options || {} 14 | 15 | var cssLoader = { 16 | loader: 'css-loader', 17 | options: { 18 | minimize: process.env.NODE_ENV === 'production', 19 | sourceMap: options.sourceMap 20 | } 21 | } 22 | 23 | // generate loader string to be used with extract text plugin 24 | function generateLoaders (loader, loaderOptions) { 25 | var loaders = [cssLoader] 26 | if (loader) { 27 | loaders.push({ 28 | loader: loader + '-loader', 29 | options: Object.assign({}, loaderOptions, { 30 | sourceMap: options.sourceMap 31 | }) 32 | }) 33 | } 34 | 35 | // Extract CSS when that option is specified 36 | // (which is the case during production build) 37 | if (options.extract) { 38 | return ExtractTextPlugin.extract({ 39 | use: loaders, 40 | fallback: 'vue-style-loader' 41 | }) 42 | } else { 43 | return ['vue-style-loader'].concat(loaders) 44 | } 45 | } 46 | 47 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 48 | return { 49 | css: generateLoaders(), 50 | postcss: generateLoaders(), 51 | less: generateLoaders('less'), 52 | sass: generateLoaders('sass', { indentedSyntax: true }), 53 | scss: generateLoaders('sass'), 54 | stylus: generateLoaders('stylus'), 55 | styl: generateLoaders('stylus') 56 | } 57 | } 58 | 59 | // Generate loaders for standalone style files (outside of .vue) 60 | exports.styleLoaders = function (options) { 61 | var output = [] 62 | var loaders = exports.cssLoaders(options) 63 | for (var extension in loaders) { 64 | var loader = loaders[extension] 65 | output.push({ 66 | test: new RegExp('\\.' + extension + '$'), 67 | use: loader 68 | }) 69 | } 70 | return output 71 | } 72 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # vue-fullpage 2 | 3 | README:[English Version](https://github.com/wendaosanshou/vue-fullpage/blob/master/README.md) 4 | > 一个基于vue.js的页面滚动插件 5 | 6 | ## 线上demo 7 | 这里有一个[线上的demo](http://vue.fecss.com/vue-fullpage/)和一个[jsfiddle demo](https://jsfiddle.net/wendaosanshou/4b6p5ujt/12/) 8 | 9 | ## 功能概述 10 | 实现了移动端的单页滚动效果,支持横向滚动和纵向滚动,支持animate.css里的所有动画指令 11 | 12 | ## 安装 13 | ``` 14 | npm install vue-fullpage --save 15 | ``` 16 | 如果你想使用动画指令,请安装``animate.css`` 17 | ``` 18 | npm install animate.css --save 19 | ``` 20 | [animate.css用法](https://daneden.github.io/animate.css/) 21 | 22 | ## 文档 23 | [api文档](https://github.com/wendaosanshou/vue-fullpage/blob/master/doc/api_cn.md) 24 | 25 | ## 快速上手 26 | 27 | #### main.js 28 | 在main.js需要引入该插件的css和js文件 29 | 30 | ```js 31 | import 'vue-fullpage/vue-fullpage.css' 32 | import VueFullpage from 'vue-fullpage' 33 | Vue.use(VueFullpage) 34 | ``` 35 | 36 | #### app.vue 37 | 38 | **template** 39 | 40 | 在``page-wp``容器上加``v-fullpage``指令,``v-fullpage``的值是fullpage的配置 41 | 在``page``容器上加``v-animate``指令,``v-animate``的值是``animate.css``的动画效果 42 | ```html 43 |
44 |
45 |
46 |

vue-fullpage

47 |
48 |
49 |

vue-fullpage

50 |
51 |
52 |

vue-fullpage

53 |

vue-fullpage

54 |

vue-fullpage

55 |
56 |
57 |
58 | ``` 59 | 60 | **js** 61 | 62 | ``vue-fullpage``的值请参考[api文档](https://github.com/wendaosanshou/vue-fullpage/blob/master/doc/api_cn.md) 63 | ```js 64 | export default { 65 | data() { 66 | return { 67 | opts: { 68 | start: 0, 69 | dir: 'v', 70 | duration: 500 71 | } 72 | } 73 | } 74 | } 75 | ``` 76 | 77 | **style** 78 | ``page-container``需要固定宽度和高度,``fullpage``会自适应父元素的宽度和高度。 79 | 如下设置可使滚动页面充满全屏 80 | ``` 81 | 90 | ``` 91 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example1", 3 | "version": "1.0.0", 4 | "description": "A Vue.js project", 5 | "author": "wendaosanshou <947809647@qq.com>", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "start": "node build/dev-server.js", 10 | "build": "node build/build.js", 11 | "lint": "eslint --ext .js,.vue src" 12 | }, 13 | "dependencies": { 14 | "animate.css": "^3.5.2", 15 | "hammer-touchemulator": "0.0.2", 16 | "highlight.js": "^9.12.0", 17 | "marked": "^0.3.6", 18 | "normalize.css": "^7.0.0", 19 | "vue": "^2.2.6", 20 | "vue-fullpage": "^2.0.4" 21 | }, 22 | "devDependencies": { 23 | "autoprefixer": "^6.7.2", 24 | "babel-core": "^6.22.1", 25 | "babel-eslint": "^7.1.1", 26 | "babel-loader": "^6.2.10", 27 | "babel-plugin-transform-runtime": "^6.22.0", 28 | "babel-preset-env": "^1.3.2", 29 | "babel-preset-stage-2": "^6.22.0", 30 | "babel-register": "^6.22.0", 31 | "chalk": "^1.1.3", 32 | "connect-history-api-fallback": "^1.3.0", 33 | "copy-webpack-plugin": "^4.0.1", 34 | "css-loader": "^0.28.0", 35 | "eslint": "^3.19.0", 36 | "eslint-config-standard": "^6.2.1", 37 | "eslint-friendly-formatter": "^2.0.7", 38 | "eslint-loader": "^1.7.1", 39 | "eslint-plugin-html": "^2.0.0", 40 | "eslint-plugin-promise": "^3.4.0", 41 | "eslint-plugin-standard": "^2.0.1", 42 | "eventsource-polyfill": "^0.9.6", 43 | "express": "^4.14.1", 44 | "extract-text-webpack-plugin": "^2.0.0", 45 | "file-loader": "^0.11.1", 46 | "friendly-errors-webpack-plugin": "^1.1.3", 47 | "html-webpack-plugin": "^2.28.0", 48 | "http-proxy-middleware": "^0.17.3", 49 | "opn": "^4.0.2", 50 | "optimize-css-assets-webpack-plugin": "^1.3.0", 51 | "ora": "^1.2.0", 52 | "precss": "^1.4.0", 53 | "raw-loader": "^0.5.1", 54 | "rimraf": "^2.6.0", 55 | "semver": "^5.3.0", 56 | "shelljs": "^0.7.6", 57 | "url-loader": "^0.5.8", 58 | "vue-loader": "^11.3.4", 59 | "vue-router": "^2.5.3", 60 | "vue-style-loader": "^2.0.5", 61 | "vue-template-compiler": "^2.2.6", 62 | "webpack": "^2.3.3", 63 | "webpack-bundle-analyzer": "^2.2.1", 64 | "webpack-dev-middleware": "^1.10.0", 65 | "webpack-hot-middleware": "^2.18.0", 66 | "webpack-merge": "^4.1.0" 67 | }, 68 | "engines": { 69 | "node": ">= 4.0.0", 70 | "npm": ">= 3.0.0" 71 | }, 72 | "browserslist": [ 73 | "> 1%", 74 | "last 2 versions", 75 | "not ie <= 8" 76 | ] 77 | } 78 | -------------------------------------------------------------------------------- /example/build/dev-server.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | var config = require('../config') 4 | if (!process.env.NODE_ENV) { 5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) 6 | } 7 | 8 | var opn = require('opn') 9 | var path = require('path') 10 | var express = require('express') 11 | var webpack = require('webpack') 12 | var proxyMiddleware = require('http-proxy-middleware') 13 | var webpackConfig = require('./webpack.dev.conf') 14 | 15 | // default port where dev server listens for incoming traffic 16 | var port = process.env.PORT || config.dev.port 17 | // automatically open browser, if not set will be false 18 | var autoOpenBrowser = !!config.dev.autoOpenBrowser 19 | // Define HTTP proxies to your custom API backend 20 | // https://github.com/chimurai/http-proxy-middleware 21 | var proxyTable = config.dev.proxyTable 22 | 23 | var app = express() 24 | var compiler = webpack(webpackConfig) 25 | 26 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 27 | publicPath: webpackConfig.output.publicPath, 28 | quiet: true 29 | }) 30 | 31 | var hotMiddleware = require('webpack-hot-middleware')(compiler, { 32 | log: () => {} 33 | }) 34 | // force page reload when html-webpack-plugin template changes 35 | compiler.plugin('compilation', function (compilation) { 36 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 37 | hotMiddleware.publish({ action: 'reload' }) 38 | cb() 39 | }) 40 | }) 41 | 42 | // proxy api requests 43 | Object.keys(proxyTable).forEach(function (context) { 44 | var options = proxyTable[context] 45 | if (typeof options === 'string') { 46 | options = { target: options } 47 | } 48 | app.use(proxyMiddleware(options.filter || context, options)) 49 | }) 50 | 51 | // handle fallback for HTML5 history API 52 | app.use(require('connect-history-api-fallback')()) 53 | 54 | // serve webpack bundle output 55 | app.use(devMiddleware) 56 | 57 | // enable hot-reload and state-preserving 58 | // compilation error display 59 | app.use(hotMiddleware) 60 | 61 | // serve pure static assets 62 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 63 | app.use(staticPath, express.static('./static')) 64 | 65 | port = 9010 66 | var uri = 'http://localhost:' + port 67 | 68 | var _resolve 69 | var readyPromise = new Promise(resolve => { 70 | _resolve = resolve 71 | }) 72 | 73 | console.log('> Starting dev server...') 74 | devMiddleware.waitUntilValid(() => { 75 | console.log('> Listening at ' + uri + '\n') 76 | // when env is testing, don't need open it 77 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 78 | opn(uri) 79 | } 80 | _resolve() 81 | }) 82 | 83 | var server = app.listen(port) 84 | 85 | module.exports = { 86 | ready: readyPromise, 87 | close: () => { 88 | server.close() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-fullpage 2 | 3 | README:[中文版](https://github.com/wendaosanshou/vue-fullpage/blob/master/README_CN.md) 4 | > A sigle-page scroll plugin based on vue.js 5 | 6 | ## overview 7 | To achieve sigle-page scroll in mobile, support horizontal scroll and vertical scroll, support all the animation instructions of animate.css. 8 | 9 | ## Online demo 10 | here's a [jsfiddle demo](https://jsfiddle.net/wendaosanshou/4b6p5ujt/12/) 11 | 12 | ## Installation 13 | ``` 14 | npm install vue-fullpage --save 15 | ``` 16 | If you want use animate instruction, please install animate.css 17 | ``` 18 | npm install animate.css --save 19 | ``` 20 | [animate.css usage](https://daneden.github.io/animate.css/) 21 | 22 | ## Document 23 | [api document](https://github.com/wendaosanshou/vue-fullpage/blob/master/doc/api.md) 24 | 25 | ## getting started 26 | 27 | #### main.js 28 | Import the plugin of css and js file in main.js 29 | 30 | ```js 31 | import 'animate.css' 32 | import 'vue-fullpage/vue-fullpage.css' 33 | import VueFullpage from 'vue-fullpage' 34 | Vue.use(VueFullpage) 35 | ``` 36 | 37 | #### app.vue 38 | 39 | **template** 40 | 41 | ``fullpage-container``、``fullpage-wp``、``page``are default class name. 42 | Add the ``v-fullpage`` command to the ``page-wp`` container. 43 | Add the ``v-animate`` command to the ``page`` container. 44 | ```html 45 |
46 |
47 |
48 |

vue-fullpage

49 |
50 |
51 |

vue-fullpage

52 |
53 |
54 |

vue-fullpage

55 |

vue-fullpage

56 |

vue-fullpage

57 |
58 |
59 |
60 | ``` 61 | 62 | **script** 63 | 64 | ``vue-fullpage`` value please refer to [api document](https://github.com/wendaosanshou/vue-fullpage/blob/master/doc/api.md) 65 | ```js 66 | export default { 67 | data() { 68 | return { 69 | opts: { 70 | start: 0, 71 | dir: 'v', 72 | duration: 500, 73 | beforeChange: function (prev, next) { 74 | }, 75 | afterChange: function (prev, next) { 76 | } 77 | } 78 | } 79 | } 80 | } 81 | ``` 82 | 83 | **style** 84 | 85 | Set the ``page-container`` container's width and height what do you want, and the ``v-fullpage`` command will adapt the width and height of the parent element. 86 | The following settings allow the scrolling page to fill the full screen. 87 | ``` 88 | 97 | ``` 98 | -------------------------------------------------------------------------------- /doc/api_cn.md: -------------------------------------------------------------------------------- 1 | # vue-fullpage文档 2 | 实现移动端的单页滚动效果,基于vue.js,目前只支持vue2.0及以上版本 3 | 4 | ## 指令 5 | ## v-fullpage 6 | 初始化``fullpage``需要的指令,需要放在``page-wp``容器上面 7 | 8 | ### vue-fullpage指令的值 9 | fullpage支持无参数的调用,每个参数都会有默认值,如果想实现自定义的功能,可以使用自定义参数。一个典型的自定义参数如下: 10 | ``` 11 | opts: { 12 | start: 0, 13 | dir: 'v', 14 | loop: false, 15 | duration: 500, 16 | beforeChange: function (prev, next) { 17 | console.log('before', prev, next) 18 | }, 19 | afterChange: function (prev, next) { 20 | console.log('after', prev, next) 21 | } 22 | } 23 | ``` 24 | #### page 25 | 每屏的选择符,默认是`` .page``。 26 | 必须给每页添加该选择符。 27 | 28 | #### start 29 | 从第几屏开始,默认是第一屏。 30 | 31 | #### duration 32 | 每屏动画的显示时间,切换页面后在``duration``时间过后才能再次切换下一页,默认为``500ms`` 33 | 34 | #### loop 35 | 是否支持循环滚动,默认为``false`` 36 | 37 | #### dir 38 | 滚动方向,默认为``v``,垂直滚动 39 | 垂直滚动:``v``,水平滚动:``h`` 40 | 41 | #### der 42 | 最小滑动距离,只有滑动距离大于最小滑动距离才会触发滚动效果 43 | 默认为:``0.1`` 44 | 45 | #### beforeChange 46 | 当页面在滑动后触发``beforeChange`` 47 | 包含两个参数``prev``和``next``,指当前页面和滑动后页面的index 48 | 在``beforeChange``方法中``return false``可以阻止页面的滑动 49 | 50 | #### afterChange 51 | 当页面滑动到下一页并且过了``duration``这个时间段后触发 52 | 包含两个参数``prev``和``next``,指当前页面和滑动后页面的index 53 | 54 | ## v-animate 55 | 可以通过该指令为元素添加动画。 56 | 57 | ### v-animate指令的值 58 | 59 | #### 下面是一个典型的自定义属性 60 | ```js 61 | { 62 | value:'bounceInLeft', 63 | delay: 0 64 | } 65 | ``` 66 | #### value 67 | 这个属性是一个元素的动画类型, 它的值取决于[animate.css](https://daneden.github.io/animate.css/) 68 | 你需要添加以下的class中的一个为这个属性的值: 69 | - bounce 70 | - flash 71 | - pulse 72 | - rubberBand 73 | - shake 74 | - headShake 75 | - swing 76 | - tada 77 | - wobble 78 | - jello 79 | - bounceIn 80 | - bounceInDown 81 | - bounceInLeft 82 | - bounceInRight 83 | - bounceInUp 84 | - bounceOut 85 | - bounceOutDown 86 | - bounceOutLeft 87 | - bounceOutRight 88 | - bounceOutUp 89 | - fadeIn 90 | - fadeInDown 91 | - fadeInDownBig 92 | - fadeInLeft 93 | - fadeInLeftBig 94 | - fadeInRight 95 | - fadeInRightBig 96 | - fadeInUp 97 | - fadeInUpBig 98 | - fadeOut 99 | - fadeOutDown 100 | - fadeOutDownBig 101 | - fadeOutLeft 102 | - fadeOutLeftBig 103 | - fadeOutRight 104 | - fadeOutRightBig 105 | - fadeOutUp 106 | - fadeOutUpBig 107 | - flipInX 108 | - flipInY 109 | - flipOutX 110 | - flipOutY 111 | - lightSpeedIn 112 | - lightSpeedOut 113 | - rotateIn 114 | - rotateInDownLeft 115 | - rotateInDownRight 116 | - rotateInUpLeft 117 | - rotateInUpRight 118 | - rotateOut 119 | - rotateOutDownLeft 120 | - rotateOutDownRight 121 | - rotateOutUpLeft 122 | - rotateOutUpRight 123 | - hinge 124 | - jackInTheBox 125 | - rollIn 126 | - rollOut 127 | - zoomIn 128 | - zoomInDown 129 | - zoomInLeft 130 | - zoomInRight 131 | - zoomInUp 132 | - zoomOut 133 | - zoomOutDown 134 | - zoomOutLeft 135 | - zoomOutRight 136 | - zoomOutUp 137 | - slideInDown 138 | - slideInLeft 139 | - slideInRight 140 | - slideInUp 141 | - slideOutDown 142 | - slideOutLeft 143 | - slideOutRight 144 | - slideOutUp 145 | 146 | #### delay 147 | this property is used for animation delay, when a page has multiple animation elements you need to use it. 148 | 149 | -------------------------------------------------------------------------------- /doc/api.md: -------------------------------------------------------------------------------- 1 | # vue-fullpage document 2 | vue-fullpage is a plugin to implement sigle page scroll, based on vue.js, Only support vue2.0 version. 3 | 4 | ## instruction 5 | ## v-fullpage 6 | A instruction for initialization vue-fullpage, need to be placed on the ``page-wp`` container. 7 | 8 | ### the value of v-fullpage instruction 9 | 10 | #### a typical custom params 11 | vue-fullpage support no parameter, every parameter has a default value, if want to custom function, you'd better to use custom parameter, there is a typical custom params: 12 | ```js 13 | opts: { 14 | start: 0, 15 | dir: 'v', 16 | loop: false, 17 | duration: 500, 18 | beforeChange: function (prev, next) { 19 | console.log('before', prev, next) 20 | }, 21 | afterChange: function (prev, next) { 22 | console.log('after', prev, next) 23 | } 24 | } 25 | ``` 26 | 27 | #### start 28 | Starting from the start screen, The default is first screen。 29 | 30 | #### duration 31 | The shortest display time for every screen, switch next screen muse after the ``duration`` time, the default tiem is 500ms. d 32 | 33 | #### loop 34 | Whether support loop scroll, the default value is false. 35 | 36 | #### dir 37 | This is the scrolling direction, the default value is ``v``, it's vertical scrolling. 38 | vertical scrolling: ``v``. 39 | horizontal scrolling: ``h``. 40 | 41 | #### der 42 | The minimum slide distance, only slide distance more than the ``der``, the page will scroll. 43 | the default value is ``0.1``. 44 | 45 | #### beforeChange 46 | The function will handle when page after scroll. 47 | contains two parameters `` prev`` and `` next``, referring to the current page and the page after the index. 48 | in the ``beforeChange`` method ``return false`` can prevent the page from sliding. 49 | 50 | #### afterChange 51 | Slide the page to the next page when after ``duration`` time period. 52 | contains two parameters ``prev`` and ``next``, referring to the current page's ``index`` and the after page's ``index``. 53 | 54 | 55 | ## v-animate 56 | Add an animation to the element. 57 | 58 | ### The value of v-animate instruction 59 | 60 | #### Here is a typical custom params 61 | ```js 62 | { 63 | value:'bounceInLeft', 64 | delay: 0 65 | } 66 | ``` 67 | #### value 68 | This property is the animation type of the element, its value reference [animate.css](https://daneden.github.io/animate.css/). 69 | you need add one of the following class as the property value. 70 | - bounce 71 | - flash 72 | - pulse 73 | - rubberBand 74 | - shake 75 | - headShake 76 | - swing 77 | - tada 78 | - wobble 79 | - jello 80 | - bounceIn 81 | - bounceInDown 82 | - bounceInLeft 83 | - bounceInRight 84 | - bounceInUp 85 | - bounceOut 86 | - bounceOutDown 87 | - bounceOutLeft 88 | - bounceOutRight 89 | - bounceOutUp 90 | - fadeIn 91 | - fadeInDown 92 | - fadeInDownBig 93 | - fadeInLeft 94 | - fadeInLeftBig 95 | - fadeInRight 96 | - fadeInRightBig 97 | - fadeInUp 98 | - fadeInUpBig 99 | - fadeOut 100 | - fadeOutDown 101 | - fadeOutDownBig 102 | - fadeOutLeft 103 | - fadeOutLeftBig 104 | - fadeOutRight 105 | - fadeOutRightBig 106 | - fadeOutUp 107 | - fadeOutUpBig 108 | - flipInX 109 | - flipInY 110 | - flipOutX 111 | - flipOutY 112 | - lightSpeedIn 113 | - lightSpeedOut 114 | - rotateIn 115 | - rotateInDownLeft 116 | - rotateInDownRight 117 | - rotateInUpLeft 118 | - rotateInUpRight 119 | - rotateOut 120 | - rotateOutDownLeft 121 | - rotateOutDownRight 122 | - rotateOutUpLeft 123 | - rotateOutUpRight 124 | - hinge 125 | - jackInTheBox 126 | - rollIn 127 | - rollOut 128 | - zoomIn 129 | - zoomInDown 130 | - zoomInLeft 131 | - zoomInRight 132 | - zoomInUp 133 | - zoomOut 134 | - zoomOutDown 135 | - zoomOutLeft 136 | - zoomOutRight 137 | - zoomOutUp 138 | - slideInDown 139 | - slideInLeft 140 | - slideInRight 141 | - slideInUp 142 | - slideOutDown 143 | - slideOutLeft 144 | - slideOutRight 145 | - slideOutUp 146 | 147 | #### delay 148 | This property is used for animation delay, when a page has multiple animation elements you need to use it. 149 | -------------------------------------------------------------------------------- /example/build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var CopyWebpackPlugin = require('copy-webpack-plugin') 8 | var HtmlWebpackPlugin = require('html-webpack-plugin') 9 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 11 | 12 | var env = config.build.env 13 | 14 | var webpackConfig = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ 17 | sourceMap: config.build.productionSourceMap, 18 | extract: true 19 | }) 20 | }, 21 | devtool: config.build.productionSourceMap ? '#source-map' : false, 22 | output: { 23 | path: config.build.assetsRoot, 24 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 25 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 26 | }, 27 | plugins: [ 28 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 29 | new webpack.DefinePlugin({ 30 | 'process.env': env 31 | }), 32 | new webpack.optimize.UglifyJsPlugin({ 33 | compress: { 34 | warnings: false 35 | }, 36 | sourceMap: true 37 | }), 38 | // extract css into its own file 39 | new ExtractTextPlugin({ 40 | filename: utils.assetsPath('css/[name].[contenthash].css') 41 | }), 42 | // Compress extracted CSS. We are using this plugin so that possible 43 | // duplicated CSS from different components can be deduped. 44 | new OptimizeCSSPlugin({ 45 | cssProcessorOptions: { 46 | safe: true 47 | } 48 | }), 49 | // generate dist index.html with correct asset hash for caching. 50 | // you can customize output by editing /index.html 51 | // see https://github.com/ampedandwired/html-webpack-plugin 52 | new HtmlWebpackPlugin({ 53 | filename: config.build.index, 54 | template: 'index.html', 55 | inject: true, 56 | minify: { 57 | removeComments: true, 58 | collapseWhitespace: true, 59 | removeAttributeQuotes: true 60 | // more options: 61 | // https://github.com/kangax/html-minifier#options-quick-reference 62 | }, 63 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 64 | chunksSortMode: 'dependency' 65 | }), 66 | // split vendor js into its own file 67 | new webpack.optimize.CommonsChunkPlugin({ 68 | name: 'vendor', 69 | minChunks: function (module, count) { 70 | // any required modules inside node_modules are extracted to vendor 71 | return ( 72 | module.resource && 73 | /\.js$/.test(module.resource) && 74 | module.resource.indexOf( 75 | path.join(__dirname, '../node_modules') 76 | ) === 0 77 | ) 78 | } 79 | }), 80 | // extract webpack runtime and module manifest to its own file in order to 81 | // prevent vendor hash from being updated whenever app bundle is updated 82 | new webpack.optimize.CommonsChunkPlugin({ 83 | name: 'manifest', 84 | chunks: ['vendor'] 85 | }), 86 | // copy custom static assets 87 | new CopyWebpackPlugin([ 88 | { 89 | from: path.resolve(__dirname, '../static'), 90 | to: config.build.assetsSubDirectory, 91 | ignore: ['.*'] 92 | } 93 | ]) 94 | ] 95 | }) 96 | 97 | if (config.build.productionGzip) { 98 | var CompressionWebpackPlugin = require('compression-webpack-plugin') 99 | 100 | webpackConfig.plugins.push( 101 | new CompressionWebpackPlugin({ 102 | asset: '[path].gz[query]', 103 | algorithm: 'gzip', 104 | test: new RegExp( 105 | '\\.(' + 106 | config.build.productionGzipExtensions.join('|') + 107 | ')$' 108 | ), 109 | threshold: 10240, 110 | minRatio: 0.8 111 | }) 112 | ) 113 | } 114 | 115 | if (config.build.bundleAnalyzerReport) { 116 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 117 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 118 | } 119 | 120 | module.exports = webpackConfig 121 | -------------------------------------------------------------------------------- /example/src/pages/home.vue: -------------------------------------------------------------------------------- 1 | 109 | 110 | 127 | 128 | 196 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict' 3 | 4 | var fullpage = {} 5 | var opt = { 6 | start: 0, 7 | duration: 500, 8 | loop: false, 9 | dir: 'v', 10 | der: 0.1, 11 | movingFlag: false, 12 | preventWechat: false, 13 | needInitAfterUpdated: false, 14 | beforeChange: function(data) {}, 15 | afterChange: function(data) {} 16 | } 17 | 18 | fullpage.install = function (Vue, options) { 19 | var that = fullpage 20 | Vue.directive('fullpage', { 21 | inserted: function (el, binding, vnode) { 22 | var opts = binding.value || {} 23 | that.init(el, opts, vnode) 24 | }, 25 | componentUpdated: function (el, binding, vnode) { 26 | if (!that.o.needInitAfterUpdated) { 27 | return 28 | } 29 | var opts = binding.value || {} 30 | that.init(el, opts, vnode) 31 | } 32 | }) 33 | 34 | Vue.directive('animate', { 35 | inserted: function (el, binding, vnode) { 36 | if (binding.value) { 37 | that.initAnimate(el, binding, vnode) 38 | } 39 | } 40 | }) 41 | } 42 | 43 | fullpage.initAnimate = function (el, binding, vnode) { 44 | var that = fullpage 45 | var vm = vnode.context 46 | var aminate = binding.value 47 | el.style.opacity = '0' 48 | vm.$on('toogle_animate', function (curIndex) { 49 | var parent = el.parentNode 50 | while(parent.getAttribute('data-id') === null) { 51 | parent = parent.parentNode 52 | } 53 | var curPage = +parent.getAttribute('data-id') 54 | if (curIndex === curPage) { 55 | that.addAnimated(el, aminate) 56 | } else { 57 | if (el.setTimeout) { 58 | clearTimeout(el.setTimeout) 59 | } 60 | el.style.opacity = '0' 61 | that.removeAnimated(el, aminate) 62 | } 63 | }) 64 | } 65 | 66 | fullpage.addAnimated = function (el, animate) { 67 | var delay = animate.delay || 0 68 | el.classList.add('animated') 69 | el.setTimeout =window.setTimeout(function () { 70 | el.style.opacity = '1' 71 | el.classList.add(animate.value) 72 | }, delay) 73 | } 74 | 75 | fullpage.removeAnimated = function (el, animate) { 76 | ar classes = el.getAttribute('class') 77 | if (classes && classes.indexOf('animated') > -1) { 78 | el.classList.remove(animate.value) 79 | } 80 | } 81 | 82 | fullpage.assignOpts = function (option) { 83 | var that = fullpage 84 | var o = option || {} 85 | for (var key in opt) { 86 | if (!o.hasOwnProperty(key)) { 87 | o[key] = opt[key] 88 | } 89 | } 90 | that.o = o 91 | } 92 | 93 | fullpage.initScrollDirection = function () { 94 | if (this.o.dir !== 'v') { 95 | this.el.classList.add('fullpage-wp-h') 96 | } 97 | } 98 | 99 | fullpage.init = function (el, options, vnode) { 100 | var that = fullpage 101 | that.assignOpts(options) 102 | 103 | that.vm = vnode.context 104 | that.vm.$fullpage = that 105 | that.curIndex = that.o.start 106 | 107 | that.startY = 0 108 | that.o.movingFlag = false 109 | 110 | that.el = el 111 | that.el.classList.add('fullpage-wp') 112 | 113 | that.parentEle = that.el.parentNode 114 | that.parentEle.classList.add('fullpage-container') 115 | 116 | that.pageEles = that.el.children 117 | that.total = that.pageEles.length 118 | 119 | that.initScrollDirection() 120 | window.setTimeout(function () { 121 | that.width = that.parentEle.offsetWidth 122 | that.height = that.parentEle.offsetHeight 123 | 124 | for (var i = 0; i < that.pageEles.length; i++) { 125 | var pageEle = that.pageEles[i] 126 | pageEle.setAttribute('data-id', i) 127 | pageEle.classList.add('page') 128 | pageEle.style.width = that.width + 'px' 129 | pageEle.style.height = that.height + 'px' 130 | that.initEvent(pageEle) 131 | } 132 | that.moveTo(that.curIndex, false) 133 | }, 0) 134 | } 135 | 136 | fullpage.initEvent = function (el) { 137 | var that = fullpage 138 | that.prevIndex = that.curIndex 139 | el.addEventListener('touchstart', function (e) { 140 | if (that.o.movingFlag) { 141 | return false 142 | } 143 | that.startX = e.targetTouches[0].pageX 144 | that.startY = e.targetTouches[0].pageY 145 | }) 146 | el.addEventListener('touchend', function(e) { 147 | if (that.o.movingFlag) { 148 | return false 149 | } 150 | var dir = that.o.dir 151 | var sub = dir === 'v' ? (e.changedTouches[0].pageY - that.startY) / that.height : (e.changedTouches[0].pageX - that.startX) / that.width 152 | var der = sub > that.o.der ? -1 : sub < -that.o.der ? 1 : 0 153 | // that.curIndex推迟到moveTo执行完之后再更新 154 | var nextIndex = that.curIndex + der 155 | 156 | if (nextIndex >= 0 && nextIndex < that.total) { 157 | that.moveTo(nextIndex, true) 158 | } else { 159 | if (that.o.loop) { 160 | nextIndex = nextIndex < 0 ? that.total - 1 : 0 161 | that.moveTo(nextIndex, true) 162 | } else { 163 | that.curIndex = nextIndex < 0 ? 0 : that.total - 1 164 | } 165 | } 166 | }) 167 | if (that.o.preventWechat) { 168 | el.addEventListener('touchmove', function(e) { 169 | e.preventDefault() 170 | }) 171 | } 172 | } 173 | 174 | fullpage.moveTo = function (curIndex, anim) { 175 | var that = fullpage 176 | var dist = that.o.dir === 'v' ? (curIndex) * (-that.height) : curIndex * (-that.width) 177 | that.o.movingFlag = true 178 | var flag = that.o.beforeChange(that.prevIndex, curIndex) 179 | if (flag === false) { 180 | // 重置movingFlag 181 | that.o.movingFlag = false 182 | return false 183 | } 184 | that.curIndex = curIndex 185 | 186 | if (anim) { 187 | that.el.classList.add('anim') 188 | } else { 189 | that.el.classList.remove('anim') 190 | } 191 | 192 | that.move(dist) 193 | window.setTimeout(function () { 194 | that.o.afterChange(that.prevIndex, curIndex) 195 | that.o.movingFlag = false 196 | that.prevIndex = curIndex 197 | that.vm.$emit('toogle_animate', curIndex) 198 | }, that.o.duration) 199 | } 200 | 201 | fullpage.move = function (dist) { 202 | var xPx = '0px' 203 | var yPx = '0px' 204 | if (this.o.dir === 'v') { 205 | yPx = dist + 'px' 206 | } else { 207 | xPx = dist + 'px' 208 | } 209 | this.el.style.cssText += ('-webkit-transform:translate3d(' + xPx + ', ' + yPx + ', 0px);transform:translate3d(' + xPx + ', ' + yPx + ', 0px);') 210 | } 211 | 212 | if (typeof exports === 'object') { 213 | module.exports = fullpage 214 | } else if (typeof define === 'function' && define.amd) { 215 | define([], function() { 216 | return fullpage 217 | }) 218 | } else if (window.Vue) { 219 | window.VueFullpage = fullpage 220 | Vue.use(fullpage) 221 | } 222 | })() 223 | -------------------------------------------------------------------------------- /example/src/assets/css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */ 2 | 3 | /* Document 4 | ========================================================================== */ 5 | 6 | /** 7 | * 1. Correct the line height in all browsers. 8 | * 2. Prevent adjustments of font size after orientation changes in 9 | * IE on Windows Phone and in iOS. 10 | */ 11 | 12 | html { 13 | line-height: 1.15; /* 1 */ 14 | -ms-text-size-adjust: 100%; /* 2 */ 15 | -webkit-text-size-adjust: 100%; /* 2 */ 16 | } 17 | 18 | /* Sections 19 | ========================================================================== */ 20 | 21 | /** 22 | * Remove the margin in all browsers (opinionated). 23 | */ 24 | 25 | body { 26 | margin: 0; 27 | } 28 | 29 | /** 30 | * Add the correct display in IE 9-. 31 | */ 32 | 33 | article, 34 | aside, 35 | footer, 36 | header, 37 | nav, 38 | section { 39 | display: block; 40 | } 41 | 42 | /** 43 | * Correct the font size and margin on `h1` elements within `section` and 44 | * `article` contexts in Chrome, Firefox, and Safari. 45 | */ 46 | 47 | h1 { 48 | font-size: 2em; 49 | margin: 0.67em 0; 50 | } 51 | 52 | /* Grouping content 53 | ========================================================================== */ 54 | 55 | /** 56 | * Add the correct display in IE 9-. 57 | * 1. Add the correct display in IE. 58 | */ 59 | 60 | figcaption, 61 | figure, 62 | main { /* 1 */ 63 | display: block; 64 | } 65 | 66 | /** 67 | * Add the correct margin in IE 8. 68 | */ 69 | 70 | figure { 71 | margin: 1em 40px; 72 | } 73 | 74 | /** 75 | * 1. Add the correct box sizing in Firefox. 76 | * 2. Show the overflow in Edge and IE. 77 | */ 78 | 79 | hr { 80 | box-sizing: content-box; /* 1 */ 81 | height: 0; /* 1 */ 82 | overflow: visible; /* 2 */ 83 | } 84 | 85 | /** 86 | * 1. Correct the inheritance and scaling of font size in all browsers. 87 | * 2. Correct the odd `em` font sizing in all browsers. 88 | */ 89 | 90 | pre { 91 | font-family: monospace, monospace; /* 1 */ 92 | font-size: 1em; /* 2 */ 93 | } 94 | 95 | /* Text-level semantics 96 | ========================================================================== */ 97 | 98 | /** 99 | * 1. Remove the gray background on active links in IE 10. 100 | * 2. Remove gaps in links underline in iOS 8+ and Safari 8+. 101 | */ 102 | 103 | a { 104 | background-color: transparent; /* 1 */ 105 | -webkit-text-decoration-skip: objects; /* 2 */ 106 | } 107 | 108 | /** 109 | * 1. Remove the bottom border in Chrome 57- and Firefox 39-. 110 | * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. 111 | */ 112 | 113 | abbr[title] { 114 | border-bottom: none; /* 1 */ 115 | text-decoration: underline; /* 2 */ 116 | text-decoration: underline dotted; /* 2 */ 117 | } 118 | 119 | /** 120 | * Prevent the duplicate application of `bolder` by the next rule in Safari 6. 121 | */ 122 | 123 | b, 124 | strong { 125 | font-weight: inherit; 126 | } 127 | 128 | /** 129 | * Add the correct font weight in Chrome, Edge, and Safari. 130 | */ 131 | 132 | b, 133 | strong { 134 | font-weight: bolder; 135 | } 136 | 137 | /** 138 | * 1. Correct the inheritance and scaling of font size in all browsers. 139 | * 2. Correct the odd `em` font sizing in all browsers. 140 | */ 141 | 142 | code, 143 | kbd, 144 | samp { 145 | font-family: monospace, monospace; /* 1 */ 146 | font-size: 1em; /* 2 */ 147 | } 148 | 149 | /** 150 | * Add the correct font style in Android 4.3-. 151 | */ 152 | 153 | dfn { 154 | font-style: italic; 155 | } 156 | 157 | /** 158 | * Add the correct background and color in IE 9-. 159 | */ 160 | 161 | mark { 162 | background-color: #ff0; 163 | color: #000; 164 | } 165 | 166 | /** 167 | * Add the correct font size in all browsers. 168 | */ 169 | 170 | small { 171 | font-size: 80%; 172 | } 173 | 174 | /** 175 | * Prevent `sub` and `sup` elements from affecting the line height in 176 | * all browsers. 177 | */ 178 | 179 | sub, 180 | sup { 181 | font-size: 75%; 182 | line-height: 0; 183 | position: relative; 184 | vertical-align: baseline; 185 | } 186 | 187 | sub { 188 | bottom: -0.25em; 189 | } 190 | 191 | sup { 192 | top: -0.5em; 193 | } 194 | 195 | /* Embedded content 196 | ========================================================================== */ 197 | 198 | /** 199 | * Add the correct display in IE 9-. 200 | */ 201 | 202 | audio, 203 | video { 204 | display: inline-block; 205 | } 206 | 207 | /** 208 | * Add the correct display in iOS 4-7. 209 | */ 210 | 211 | audio:not([controls]) { 212 | display: none; 213 | height: 0; 214 | } 215 | 216 | /** 217 | * Remove the border on images inside links in IE 10-. 218 | */ 219 | 220 | img { 221 | border-style: none; 222 | } 223 | 224 | /** 225 | * Hide the overflow in IE. 226 | */ 227 | 228 | svg:not(:root) { 229 | overflow: hidden; 230 | } 231 | 232 | /* Forms 233 | ========================================================================== */ 234 | 235 | /** 236 | * 1. Change the font styles in all browsers (opinionated). 237 | * 2. Remove the margin in Firefox and Safari. 238 | */ 239 | 240 | button, 241 | input, 242 | optgroup, 243 | select, 244 | textarea { 245 | font-family: sans-serif; /* 1 */ 246 | font-size: 100%; /* 1 */ 247 | line-height: 1.15; /* 1 */ 248 | margin: 0; /* 2 */ 249 | } 250 | 251 | /** 252 | * Show the overflow in IE. 253 | * 1. Show the overflow in Edge. 254 | */ 255 | 256 | button, 257 | input { /* 1 */ 258 | overflow: visible; 259 | } 260 | 261 | /** 262 | * Remove the inheritance of text transform in Edge, Firefox, and IE. 263 | * 1. Remove the inheritance of text transform in Firefox. 264 | */ 265 | 266 | button, 267 | select { /* 1 */ 268 | text-transform: none; 269 | } 270 | 271 | /** 272 | * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video` 273 | * controls in Android 4. 274 | * 2. Correct the inability to style clickable types in iOS and Safari. 275 | */ 276 | 277 | button, 278 | html [type="button"], /* 1 */ 279 | [type="reset"], 280 | [type="submit"] { 281 | -webkit-appearance: button; /* 2 */ 282 | } 283 | 284 | /** 285 | * Remove the inner border and padding in Firefox. 286 | */ 287 | 288 | button::-moz-focus-inner, 289 | [type="button"]::-moz-focus-inner, 290 | [type="reset"]::-moz-focus-inner, 291 | [type="submit"]::-moz-focus-inner { 292 | border-style: none; 293 | padding: 0; 294 | } 295 | 296 | /** 297 | * Restore the focus styles unset by the previous rule. 298 | */ 299 | 300 | button:-moz-focusring, 301 | [type="button"]:-moz-focusring, 302 | [type="reset"]:-moz-focusring, 303 | [type="submit"]:-moz-focusring { 304 | outline: 1px dotted ButtonText; 305 | } 306 | 307 | /** 308 | * Correct the padding in Firefox. 309 | */ 310 | 311 | fieldset { 312 | padding: 0.35em 0.75em 0.625em; 313 | } 314 | 315 | /** 316 | * 1. Correct the text wrapping in Edge and IE. 317 | * 2. Correct the color inheritance from `fieldset` elements in IE. 318 | * 3. Remove the padding so developers are not caught out when they zero out 319 | * `fieldset` elements in all browsers. 320 | */ 321 | 322 | legend { 323 | box-sizing: border-box; /* 1 */ 324 | color: inherit; /* 2 */ 325 | display: table; /* 1 */ 326 | max-width: 100%; /* 1 */ 327 | padding: 0; /* 3 */ 328 | white-space: normal; /* 1 */ 329 | } 330 | 331 | /** 332 | * 1. Add the correct display in IE 9-. 333 | * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera. 334 | */ 335 | 336 | progress { 337 | display: inline-block; /* 1 */ 338 | vertical-align: baseline; /* 2 */ 339 | } 340 | 341 | /** 342 | * Remove the default vertical scrollbar in IE. 343 | */ 344 | 345 | textarea { 346 | overflow: auto; 347 | } 348 | 349 | /** 350 | * 1. Add the correct box sizing in IE 10-. 351 | * 2. Remove the padding in IE 10-. 352 | */ 353 | 354 | [type="checkbox"], 355 | [type="radio"] { 356 | box-sizing: border-box; /* 1 */ 357 | padding: 0; /* 2 */ 358 | } 359 | 360 | /** 361 | * Correct the cursor style of increment and decrement buttons in Chrome. 362 | */ 363 | 364 | [type="number"]::-webkit-inner-spin-button, 365 | [type="number"]::-webkit-outer-spin-button { 366 | height: auto; 367 | } 368 | 369 | /** 370 | * 1. Correct the odd appearance in Chrome and Safari. 371 | * 2. Correct the outline style in Safari. 372 | */ 373 | 374 | [type="search"] { 375 | -webkit-appearance: textfield; /* 1 */ 376 | outline-offset: -2px; /* 2 */ 377 | } 378 | 379 | /** 380 | * Remove the inner padding and cancel buttons in Chrome and Safari on macOS. 381 | */ 382 | 383 | [type="search"]::-webkit-search-cancel-button, 384 | [type="search"]::-webkit-search-decoration { 385 | -webkit-appearance: none; 386 | } 387 | 388 | /** 389 | * 1. Correct the inability to style clickable types in iOS and Safari. 390 | * 2. Change font properties to `inherit` in Safari. 391 | */ 392 | 393 | ::-webkit-file-upload-button { 394 | -webkit-appearance: button; /* 1 */ 395 | font: inherit; /* 2 */ 396 | } 397 | 398 | /* Interactive 399 | ========================================================================== */ 400 | 401 | /* 402 | * Add the correct display in IE 9-. 403 | * 1. Add the correct display in Edge, IE, and Firefox. 404 | */ 405 | 406 | details, /* 1 */ 407 | menu { 408 | display: block; 409 | } 410 | 411 | /* 412 | * Add the correct display in all browsers. 413 | */ 414 | 415 | summary { 416 | display: list-item; 417 | } 418 | 419 | /* Scripting 420 | ========================================================================== */ 421 | 422 | /** 423 | * Add the correct display in IE 9-. 424 | */ 425 | 426 | canvas { 427 | display: inline-block; 428 | } 429 | 430 | /** 431 | * Add the correct display in IE. 432 | */ 433 | 434 | template { 435 | display: none; 436 | } 437 | 438 | /* Hidden 439 | ========================================================================== */ 440 | 441 | /** 442 | * Add the correct display in IE 10-. 443 | */ 444 | 445 | [hidden] { 446 | display: none; 447 | } 448 | --------------------------------------------------------------------------------