vue-scroll
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,12 +0,6 @@ | ||
;(function(undefined){ | ||
var Vue = require('vue'); | ||
var Vue; | ||
if(window && window.Vue){ | ||
Vue = window.Vue; | ||
}else if(!require){ | ||
Vue = require('Vue'); | ||
} | ||
//Common part start | ||
if(!Vue) { | ||
@@ -25,6 +19,6 @@ throw new Error('Please load vue.js before install current plugin'); | ||
vm = this.vm, | ||
callBack = vm[self.expression]; | ||
listener = vm[self.expression]; | ||
if(el.addEventListener){ | ||
el.addEventListener('scroll',function(e){ | ||
callBack && callBack(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
listener && listener(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
}); | ||
@@ -34,3 +28,3 @@ }else{ | ||
var e = window.event; | ||
callBack && callBack(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
listener && listener(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
}); | ||
@@ -40,3 +34,3 @@ } | ||
}, | ||
update: function (newValue, oldValue) { | ||
update: function (newListener, oldListener) { | ||
//replace old listener by new listener | ||
@@ -46,11 +40,11 @@ var self = this, | ||
if(el.addEventListener){ | ||
el.removeEventListener('scroll',oldValue); | ||
el.removeEventListener('scroll',oldListener); | ||
el.addEventListener('scroll',function(e){ | ||
newValue && newValue(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
newListener && newListener(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
}); | ||
}else { | ||
el.detachEvent('onscroll',oldValue); | ||
el.detachEvent('onscroll',oldListener); | ||
el.attach('onscroll',function(){ | ||
var e = window.event; | ||
newValue && newValue(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
newListener && newListener(e, { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}); | ||
}); | ||
@@ -63,7 +57,7 @@ } | ||
vm = this.vm, | ||
callBack = vm[self.expression]; | ||
listener = vm[self.expression]; | ||
if(el.removeEventListener){ | ||
el.removeEventListener('scroll',callBack); | ||
el.removeEventListener('scroll',listener); | ||
}else{ | ||
el.detachEvent('onscroll',callBack); | ||
el.detachEvent('onscroll',listener); | ||
} | ||
@@ -75,9 +69,8 @@ } | ||
if(window){ | ||
Vue.use(vScroll); | ||
}else{ | ||
module.exports = vScroll; | ||
} | ||
Vue.use(vScroll); | ||
//Common part end | ||
module.exports = vScroll; | ||
})(undefined) | ||
{ | ||
"name": "vue-scroll", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "scroll directive for vuejs", | ||
@@ -21,3 +21,6 @@ "main": "index.js", | ||
"author": "wangpin", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"dependencies": { | ||
"vue": "^1.0.24" | ||
} | ||
} |
@@ -6,23 +6,21 @@ # vue-scroll | ||
# Installation | ||
## NPM(recommended) | ||
## Installation | ||
### NPM(recommended) | ||
``` | ||
npm install vue-scroll --save-dev | ||
npm install vue-scroll --save | ||
``` | ||
You need to load it manually. | ||
And it is necessary to import it explicitly | ||
``` | ||
const Vue = require('vue') | ||
const vScroll = require('vue-scroll') | ||
Vue.use(vScroll) | ||
require('vue-scroll') | ||
``` | ||
## Standlone | ||
### Standlone | ||
Simple download and include it in script tag. And it will be auto loaded into vue. | ||
Simple download and include it in script tag. | ||
* [dev-version](http://cdn.rawgit.com/wangpin34/vue-scroll/master/lib/vue-scroll.js) | ||
* [product-version(compressed)](http://cdn.rawgit.com/wangpin34/vue-scroll/master/dist/vue-scroll.min.js) | ||
* [dev-version](http://rawgit.com/wangpin34/vue-scroll/master/lib/vue-scroll.browser.js) | ||
* [product-version(compressed)](http://rawgit.com/wangpin34/vue-scroll/master/dist/vue-scroll.min.js) | ||
# Usage | ||
## Usage | ||
It's very simple, just declar in html tags and provide a defined callback - the scroll function below. | ||
@@ -57,6 +55,8 @@ | ||
# Plain sample | ||
* [Hello World](http://cdn.rawgit.com/wangpin34/vue-scroll/master/sample/index.html) | ||
## Example | ||
# LICENSE | ||
* [Hello World](http://rawgit.com/wangpin34/vue-scroll/master/sample/index.html) | ||
## LICENSE | ||
MIT |
Sorry, the diff of this file is not supported yet
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
10741
9
115
1
+ Addedvue@^1.0.24
+ Addedacorn@5.7.4(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedast-types@0.9.6(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase62@1.2.8(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcommoner@0.10.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddefined@1.0.1(transitive)
+ Addeddetective@4.7.1(transitive)
+ Addedenvify@3.4.1(transitive)
+ Addedesprima@3.1.3(transitive)
+ Addedesprima-fb@15001.1.0-dev-harmony-fb(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjstransform@11.0.3(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedobject-assign@2.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedq@1.5.1(transitive)
+ Addedrecast@0.11.23(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsource-map@0.4.40.5.7(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedvue@1.0.28(transitive)
+ Addedwrappy@1.0.2(transitive)