vue-scroll-behavior
Advanced tools
Comparing version 0.1.1 to 0.1.2
/** | ||
* vue-scroll-behavior v0.1.0 | ||
* vue-scroll-behavior v0.1.1 | ||
* (c) 2017 jeneser <jeneserwang@gmail.com> | ||
* @license MIT | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.vueScrollBehavior=t()}(this,function(){"use strict";function e(){return document.getElementsByTagName("body")[0].scrollTop}function t(e){document.getElementsByTagName("body")[0].scrollTop=e}var o={};return o.install=function(o,n){o.historyList=[],o.vueScrollBehavior=function(o){var n=this;void 0!==o?(o.beforeEach(function(t,o,i){var r=e(),u=n.historyList.findIndex(function(e){return e.path===o.fullPath});-1!==u?n.historyList[u].position=r:n.historyList.push({path:o.fullPath,position:r}),i()}),o.afterEach(function(e){t((n.historyList.find(function(t){return t.path===e.fullPath})||0).position)})):console.warn("vue-scroll-behavior dependent on vue-router! Please Create the router instance.")}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(o),o}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.vueScrollBehavior=e()}(this,function(){"use strict";function t(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0}function e(t){window.pageYOffset=t,document.documentElement.scrollTop=t,document.body.scrollTop=t}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=(function(){function t(t){this.value=t}function e(e){function o(t,e){return new Promise(function(o,r){var c={key:t,arg:e,resolve:o,reject:r,next:null};u?u=u.next=c:(i=u=c,n(t,e))})}function n(o,i){try{var u=e[o](i),c=u.value;c instanceof t?Promise.resolve(c.value).then(function(t){n("next",t)},function(t){n("throw",t)}):r(u.done?"return":"normal",u.value)}catch(t){r("throw",t)}}function r(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}i=i.next,i?n(i.key,i.arg):u=null}var i,u;this._invoke=o,"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),{});return n.install=function(n,r){n.historyList=[],n.vueScrollBehavior=function(n){var r=this;"object"===(void 0===n?"undefined":o(n))&&"function"==typeof n.beforeEach?(n.beforeEach(function(e,o,n){var i=t(),u=r.historyList.findIndex(function(t){return t.path===o.fullPath});-1!==u?r.historyList[u].position=i:r.historyList.push({path:o.fullPath,position:i}),n()}),n.afterEach(function(t){e((r.historyList.find(function(e){return e.path===t.fullPath})||0).position)})):console.warn("vue-scroll-behavior dependent on vue-router! Please Create the router instance.")}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(n),n}); |
{ | ||
"name": "vue-scroll-behavior", | ||
"description": "Scroll behavior for Vue.js", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"private": false, | ||
@@ -29,3 +29,6 @@ "main": "dist/vue-scroll-behavior.js", | ||
"scripts": { | ||
"build": "node build", | ||
"dev": "node build/dev-server.js", | ||
"build": "npm run build:library && npm run build:demo", | ||
"build:demo": "node build/build.js", | ||
"build:library": "node build/build.rollup.js", | ||
"test": "npm run build" | ||
@@ -42,4 +45,48 @@ }, | ||
"rollup-plugin-babel": "^2.6.1", | ||
"rollup-plugin-uglify": "^1.0.1" | ||
} | ||
"rollup-plugin-uglify": "^1.0.1", | ||
"vue": "^2.3.3", | ||
"vue-router": "^2.3.1", | ||
"autoprefixer": "^6.7.2", | ||
"babel-core": "^6.22.1", | ||
"babel-loader": "^6.2.10", | ||
"babel-plugin-transform-runtime": "^6.22.0", | ||
"babel-preset-env": "^1.3.2", | ||
"babel-preset-stage-2": "^6.22.0", | ||
"babel-register": "^6.22.0", | ||
"chalk": "^1.1.3", | ||
"connect-history-api-fallback": "^1.3.0", | ||
"copy-webpack-plugin": "^4.0.1", | ||
"css-loader": "^0.28.0", | ||
"eventsource-polyfill": "^0.9.6", | ||
"express": "^4.14.1", | ||
"extract-text-webpack-plugin": "^2.0.0", | ||
"file-loader": "^0.11.1", | ||
"friendly-errors-webpack-plugin": "^1.1.3", | ||
"html-webpack-plugin": "^2.28.0", | ||
"http-proxy-middleware": "^0.17.3", | ||
"webpack-bundle-analyzer": "^2.2.1", | ||
"semver": "^5.3.0", | ||
"shelljs": "^0.7.6", | ||
"opn": "^4.0.2", | ||
"optimize-css-assets-webpack-plugin": "^1.3.0", | ||
"ora": "^1.2.0", | ||
"rimraf": "^2.6.0", | ||
"url-loader": "^0.5.8", | ||
"vue-loader": "^12.1.0", | ||
"vue-style-loader": "^3.0.1", | ||
"vue-template-compiler": "^2.3.3", | ||
"webpack": "^2.6.1", | ||
"webpack-dev-middleware": "^1.10.0", | ||
"webpack-hot-middleware": "^2.18.0", | ||
"webpack-merge": "^4.1.0" | ||
}, | ||
"engines": { | ||
"node": ">= 4.0.0", | ||
"npm": ">= 3.0.0" | ||
}, | ||
"browserslist": [ | ||
"> 1%", | ||
"last 2 versions", | ||
"not ie <= 8" | ||
] | ||
} |
@@ -5,3 +5,3 @@ ## vue-scroll-behavior | ||
[![npm version](https://badge.fury.io/js/vue-scroll-behavior.svg)](https://badge.fury.io/js/vue-scroll-behavior) [![Build Status](https://travis-ci.org/jeneser/vue-scroll-behavior.svg?branch=master)](https://travis-ci.org/jeneser/vue-scroll-behavior) [![David](https://img.shields.io/david/expressjs/express.svg?style=flat-square)](https://github.com/jeneser/douban) [![Percentage of issues still open](http://isitmaintained.com/badge/open/jeneser/vue-scroll-behavior.svg)](http://isitmaintained.com/project/jeneser/vue-scroll-behavior "Percentage of issues still open") [![PR](https://img.shields.io/badge/PR-welcome-brightgreen.svg)](https://github.com/jeneser/douban/pulls) [![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/jeneser/douban/blob/master/LICENSE) | ||
[![npm version](https://badge.fury.io/js/vue-scroll-behavior.svg)](https://badge.fury.io/js/vue-scroll-behavior) [![Build Status](https://travis-ci.org/jeneser/vue-scroll-behavior.svg?branch=master)](https://travis-ci.org/jeneser/vue-scroll-behavior) [![David](https://img.shields.io/david/expressjs/express.svg?style=flat-square)](https://github.com/jeneser/douban) [![Percentage of issues still open](http://isitmaintained.com/badge/open/jeneser/vue-scroll-behavior.svg)](http://isitmaintained.com/project/jeneser/vue-scroll-behavior "Percentage of issues still open") [![PR](https://img.shields.io/badge/PR-welcome-brightgreen.svg)](https://github.com/jeneser/vue-scroll-behavior/pulls) [![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/jeneser/vue-scroll-behavior/blob/master/LICENSE) | ||
@@ -8,0 +8,0 @@ | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/edge.png" alt="IE / Edge" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/firefox.png" alt="Firefox" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/chrome.png" alt="Chrome" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/safari.png" alt="Safari" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/opera.png" alt="Opera" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Opera | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/safari-ios.png" alt="iOS Safari" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>iOS | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/chrome-android.png" alt="Chrome for Android" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Android | |
@@ -5,3 +5,4 @@ /** | ||
export function getScrollTop() { | ||
return document.getElementsByTagName('body')[0].scrollTop | ||
return window.pageYOffset || document.documentElement.scrollTop | ||
|| document.body.scrollTop || 0 | ||
} | ||
@@ -13,3 +14,5 @@ | ||
export function setScrollTop(value) { | ||
document.getElementsByTagName('body')[0].scrollTop = value | ||
window.pageYOffset = value | ||
document.documentElement.scrollTop = value | ||
document.body.scrollTop = value | ||
} |
@@ -21,3 +21,3 @@ /** | ||
if (typeof router !== 'undefined') { | ||
if (typeof router === 'object' && typeof router.beforeEach === 'function') { | ||
// Router beforeEach | ||
@@ -24,0 +24,0 @@ router.beforeEach((to, from, next) => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11968
6
81
43