vue-scroll-behavior
Advanced tools
Comparing version 0.1.2 to 0.1.3
/** | ||
* vue-scroll-behavior v0.1.1 | ||
* vue-scroll-behavior v0.1.2 | ||
* (c) 2017 jeneser <jeneserwang@gmail.com> | ||
* @license MIT | ||
*/ | ||
!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}); | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):t.vueScrollBehavior=o()}(this,function(){"use strict";function t(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop}function o(t){window.scrollTo(0,t)}var e="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 o(o){function e(t,o){return new Promise(function(e,r){var f={key:t,arg:o,resolve:e,reject:r,next:null};u?u=u.next=f:(i=u=f,n(t,o))})}function n(e,i){try{var u=o[e](i),f=u.value;f instanceof t?Promise.resolve(f.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,o){switch(t){case"return":i.resolve({value:o,done:!0});break;case"throw":i.reject(o);break;default:i.resolve({value:o,done:!1})}i=i.next,i?n(i.key,i.arg):u=null}var i,u;this._invoke=e,"function"!=typeof o.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(o.prototype[Symbol.asyncIterator]=function(){return this}),o.prototype.next=function(t){return this._invoke("next",t)},o.prototype.throw=function(t){return this._invoke("throw",t)},o.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":e(n))&&"function"==typeof n.beforeEach?(n.beforeEach(function(o,e,n){var i=t(),u=r.historyList.findIndex(function(t){return t.path===e.fullPath});-1!==u?r.historyList[u].position=i:r.historyList.push({path:e.fullPath,position:i}),n()}),n.afterEach(function(t){var e=r.historyList.find(function(o){return o.path===t.fullPath});o(void 0!==e?e.position:0)})):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.2", | ||
"version": "0.1.3", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "dist/vue-scroll-behavior.js", |
@@ -23,4 +23,8 @@ ## vue-scroll-behavior | ||
## Demo | ||
You can check vue-scroll-behavior demo at **https://jeneser.github.io/douban** | ||
You can check vue-scroll-behavior demos at: | ||
Douban: **https://jeneser.github.io/douban** | ||
Simple: **https://jeneser.github.io/vue-scroll-behavior** | ||
## Installation | ||
@@ -62,3 +66,11 @@ | ||
For additional examples and detailed description check the demo. **https://jeneser.github.io/douban** | ||
You can clone this repository. then | ||
```bash | ||
# install dependencies | ||
npm install | ||
# serve with hot reload at localhost:8080 | ||
npm run dev | ||
``` | ||
## Options | ||
@@ -70,2 +82,8 @@ | ||
- June 4, 2017: | ||
- Fix some bug, Perform browser testing | ||
- Publish @0.1.2 | ||
- June 5, 2017: | ||
- Publish @0.1.3 | ||
## Contribute | ||
@@ -75,4 +93,15 @@ | ||
```bash | ||
# install dependencies | ||
npm install | ||
# serve with hot reload at localhost:8080 | ||
npm run dev | ||
# build library and demo for production | ||
npm run build | ||
``` | ||
## License | ||
[MIT](https://github.com/jeneser/douban/blob/master/LICENSE) Copyright (c) 2017 Jeneser |
@@ -6,3 +6,3 @@ /** | ||
return window.pageYOffset || document.documentElement.scrollTop | ||
|| document.body.scrollTop || 0 | ||
|| document.body.scrollTop | ||
} | ||
@@ -14,5 +14,3 @@ | ||
export function setScrollTop(value) { | ||
window.pageYOffset = value | ||
document.documentElement.scrollTop = value | ||
document.body.scrollTop = value | ||
window.scrollTo(0, value) | ||
} |
/** | ||
* vue-scroll-behavior v0.1.0 | ||
* vue-scroll-behavior v0.1.3 | ||
* (c) 2017 jeneser | ||
@@ -47,5 +47,9 @@ * @license MIT | ||
return e.path === route.fullPath | ||
}) || 0 | ||
}) | ||
setScrollTop(savedPosition.position) | ||
if (typeof savedPosition !== 'undefined') { | ||
setScrollTop(savedPosition.position) | ||
} else { | ||
setScrollTop(0) | ||
} | ||
}) | ||
@@ -52,0 +56,0 @@ |
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
12414
83
104