Comparing version
@@ -1,2 +0,2 @@ | ||
/* appear 0.0.7 */ | ||
/* appear 0.0.9 */ | ||
appear = (function(){ | ||
@@ -107,3 +107,3 @@ 'use strict'; | ||
// call the appear fn | ||
if(opts.appear(n)) { | ||
if(opts.appear) { | ||
opts.appear(n); | ||
@@ -110,0 +110,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/* appear 0.0.7 */ | ||
appear=function(){"use strict";function e(){var e=window.scrollY;null!=n&&(r.velocity=e-n,r.delta=r.velocity>=0?r.velocity:-1*r.velocity),n=e,i&&clearTimeout(i),i=setTimeout(function(){n=null},30)}function t(e,t){var n=e.getBoundingClientRect();return n.top+n.height>=0&&n.left+n.width>=0&&n.bottom-n.height<=(window.innerHeight||document.documentElement.clientHeight)+t&&n.right-n.width<=(window.innerWidth||document.documentElement.clientWidth)+t}var n=null,i=0,r={};return addEventListener("scroll",e),function(e){return function(){function e(e,t){return function(){var n=this,i=arguments;clearTimeout(p),p=setTimeout(function(){e.apply(n,i)},t)}}function n(){r.delta<y.delta.speed&&(l||(l=!0,u(),setTimeout(function(){l=!1},y.delta.timeout))),e(function(){u()},y.debounce)()}function i(){u(),addEventListener("scroll",n),addEventListener("resize",n)}function o(){m=[],p&&clearTimeout(p),a()}function a(){removeEventListener("scroll",n),removeEventListener("resize",n)}function u(){s||(m.forEach(function(e,n){e&&t(e,y.bounds)?v[n]&&(v[n]=!1,h++,y.appear(e)&&y.appear(e),y.disappear||y.reappear||(m[n]=null)):(v[n]===!1&&(y.disappear&&y.disappear(e),g++,y.reappear||(m[n]=null)),v[n]=!0)}),y.reappear||y.appear&&(!y.appear||h!==c)||y.disappear&&(!y.disappear||g!==c)||(s=!0,a(),y.done&&y.done()))}function d(){if(!f){f=!0,y.init&&y.init();var e;if(e="function"==typeof y.elements?y.elements():y.elements){c=e.length;for(var t=0;c>t;t+=1)m.push(e[t]),v.push(!0);i()}}}var c,p,l,s,f=!1,m=[],v=[],h=0,g=0,y={};return function(e){return e=e||{},y={init:e.init,elements:e.elements,appear:e.appear,disappear:e.disappear,done:e.done,reappear:e.reappear,bounds:e.bounds||0,debounce:e.debounce||50,delta:{speed:e.deltaSpeed||50,timeout:e.deltaTimeout||500}},addEventListener("DOMContentLoaded",d),("interactive"===document.readyState||"complete"===document.readyState)&&d(),{trigger:function(){u()},pause:function(){a()},resume:function(){i()},destroy:function(){o()}}}}()(e)}}(); | ||
/* appear 0.0.9 */ | ||
appear=function(){"use strict";function e(){var e=window.scrollY;null!=n&&(r.velocity=e-n,r.delta=r.velocity>=0?r.velocity:-1*r.velocity),n=e,i&&clearTimeout(i),i=setTimeout(function(){n=null},30)}function t(e,t){var n=e.getBoundingClientRect();return n.top+n.height>=0&&n.left+n.width>=0&&n.bottom-n.height<=(window.innerHeight||document.documentElement.clientHeight)+t&&n.right-n.width<=(window.innerWidth||document.documentElement.clientWidth)+t}var n=null,i=0,r={};return addEventListener("scroll",e),function(e){return function(){function e(e,t){return function(){var n=this,i=arguments;clearTimeout(p),p=setTimeout(function(){e.apply(n,i)},t)}}function n(){r.delta<y.delta.speed&&(l||(l=!0,u(),setTimeout(function(){l=!1},y.delta.timeout))),e(function(){u()},y.debounce)()}function i(){u(),addEventListener("scroll",n),addEventListener("resize",n)}function o(){m=[],p&&clearTimeout(p),a()}function a(){removeEventListener("scroll",n),removeEventListener("resize",n)}function u(){s||(m.forEach(function(e,n){e&&t(e,y.bounds)?v[n]&&(v[n]=!1,h++,y.appear&&y.appear(e),y.disappear||y.reappear||(m[n]=null)):(v[n]===!1&&(y.disappear&&y.disappear(e),g++,y.reappear||(m[n]=null)),v[n]=!0)}),y.reappear||y.appear&&(!y.appear||h!==c)||y.disappear&&(!y.disappear||g!==c)||(s=!0,a(),y.done&&y.done()))}function d(){if(!f){f=!0,y.init&&y.init();var e;if(e="function"==typeof y.elements?y.elements():y.elements){c=e.length;for(var t=0;c>t;t+=1)m.push(e[t]),v.push(!0);i()}}}var c,p,l,s,f=!1,m=[],v=[],h=0,g=0,y={};return function(e){return e=e||{},y={init:e.init,elements:e.elements,appear:e.appear,disappear:e.disappear,done:e.done,reappear:e.reappear,bounds:e.bounds||0,debounce:e.debounce||50,delta:{speed:e.deltaSpeed||50,timeout:e.deltaTimeout||500}},addEventListener("DOMContentLoaded",d),("interactive"===document.readyState||"complete"===document.readyState)&&d(),{trigger:function(){u()},pause:function(){a()},resume:function(){i()},destroy:function(){o()}}}}()(e)}}(); |
@@ -19,7 +19,7 @@ 'use strict'; | ||
gulp.task('ghpages', function(cb) { | ||
var readme = fs.readFileSync(path.join(process.cwd(), 'README.md'), 'utf8'); | ||
data.js.appear = fs.readFileSync(path.join(process.cwd(), 'dist', 'appear.min.js'), 'utf8'); | ||
data.js.appear = fs.readFileSync(path.join(process.cwd(), 'lib', 'appear.js'), 'utf8'); | ||
data.js.appearmin = fs.readFileSync(path.join(process.cwd(), 'dist', 'appear.min.js'), 'utf8'); | ||
@@ -34,5 +34,10 @@ readme = readme.split('\n'); | ||
data.page = 'main'; | ||
var dest = path.join(process.cwd(), '..', 'appear-ghpages'); | ||
fs.writeFileSync(path.join(process.cwd(), 'ghpages', 'index.html'), templates.main(data)); | ||
fs.writeFileSync(path.join(dest, 'index.html'), templates.index(data)); | ||
data.title = ' - simple example'; | ||
fs.writeFileSync(path.join(dest, 'examples', 'simple', 'index.html'), templates['examples/simple/index'](data)); | ||
data.title = ' - lazyload example'; | ||
fs.writeFileSync(path.join(dest, 'examples', 'lazy', 'index.html'), templates['examples/lazy/index'](data)); | ||
cb(); | ||
@@ -39,0 +44,0 @@ |
@@ -106,3 +106,3 @@ appear = (function(){ | ||
// call the appear fn | ||
if(opts.appear(n)) { | ||
if(opts.appear) { | ||
opts.appear(n); | ||
@@ -109,0 +109,0 @@ } |
{ | ||
"name": "appear", | ||
"version": "0.0.7", | ||
"version": "0.0.9", | ||
"description": "utility to run functions when dom elements are visible", | ||
@@ -5,0 +5,0 @@ "kewords": "detect viewable elements dom lazy load scroll ", |
@@ -5,2 +5,7 @@ #  appear | ||
## Demos | ||
- [Simple test page](http://creativelive.github.io/appear/examples/simple/) | ||
- [Lazy loading images](http://creativelive.github.io/appear/examples/lazy/) | ||
## Usage | ||
@@ -45,4 +50,2 @@ | ||
See [creativelive.github.io/appear](http://creativelive.github.io/appear/) for more example usage. | ||
## api | ||
@@ -49,0 +52,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
526
0.96%66
4.76%97623
-12.69%