Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Apr 21, 2012
1 parent 458cb81 commit 395a007
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
19 changes: 10 additions & 9 deletions js/stroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
return false;
}

// TODO: A current limitation is that there must be at least one
// item in the list when binding.
// TODO: Create and measure element if the list is empty.

var items = Array.prototype.slice.apply( list.children );

Expand Down Expand Up @@ -102,11 +101,13 @@
active = true;
refresh();
}
};
}

/**
* Stops monitoring a list element and removes any classes
* that were applied to its list items.
*
* @param {HTMLElement} list
*/
function remove( list ) {
for( var i = 0; i < lists.length; i++ ) {
Expand All @@ -129,7 +130,7 @@
if( lists.length === 0 ) {
active = false;
}
};
}

/**
* Checks if the specified element has already been bound.
Expand All @@ -141,7 +142,7 @@
}
}
return false;
};
}

/**
* Calls 'method' for each DOM element discovered in
Expand Down Expand Up @@ -175,14 +176,14 @@
else {
throw 'Stroll target was of unexpected type.';
}
};
}

/**
* Checks if the client is capable of running the library.
*/
function isCapable() {
return !!document.body.classList;
};
}

/**
* Public API
Expand All @@ -205,7 +206,7 @@
batch( target, remove );
}
}
};
}

window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
Expand All @@ -216,6 +217,6 @@
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
})()

})();
22 changes: 11 additions & 11 deletions js/stroll.min.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*!
* stroll.js - CSS scrolling effects
* stroll.js - CSS scroll effects
* http://lab.hakim.se/scroll-effects
* MIT licensed
*
* Created by Hakim El Hattab, http://hakim.se
*/
(function(){var b=[];
var h=false;function f(){if(h){requestAnimFrame(f);for(var l=0,k=b.length;l<k;l++){b[l].update();}}}function g(o){if(e(o)||!o.nodeName||/^(ul|li)$/i.test(o.nodeName)===false){return false;
}var l=Array.prototype.slice.apply(o.children);var m=o.offsetHeight;for(var n=0,k=l.length;n<k;n++){l[n]._offsetTop=l[n].offsetTop;l[n]._offsetHeight=l[n].offsetHeight;
}b.push({domElement:o,update:function(){var t=o.pageYOffset||o.scrollTop,s=t+m;if(t!==o.lastTop){o.lastTop=t;for(var q=0,p=l.length;q<p;q++){var r=l[q];
var u=r.className;if(r._offsetTop+r._offsetHeight<t){if(u.indexOf("past")===-1){r.classList.add("past");}}else{if(r._offsetTop>s){if(u.indexOf("future")===-1){r.classList.add("future");
}}else{if(u.length){r.classList.remove("past");r.classList.remove("future");}}}}}}});if(b.length===1){h=true;f();}}function a(p){for(var n=0;n<b.length;
var h=false;function f(){if(h){requestAnimFrame(f);for(var k=0,j=b.length;k<j;k++){b[k].update();}}}function g(n){if(e(n)||!n.nodeName||/^(ul|li)$/i.test(n.nodeName)===false){return false;
}var k=Array.prototype.slice.apply(n.children);var l=n.offsetHeight;for(var m=0,j=k.length;m<j;m++){k[m]._offsetTop=k[m].offsetTop;k[m]._offsetHeight=k[m].offsetHeight;
}b.push({domElement:n,update:function(s){var t=n.pageYOffset||n.scrollTop,r=t+l;if(t!==n.lastTop){n.lastTop=t;for(var p=0,o=k.length;p<o;p++){var q=k[p];
var u=q.className;if(q._offsetTop+q._offsetHeight<t){if(u.indexOf("past")===-1){q.classList.add("past");}}else{if(q._offsetTop>r){if(u.indexOf("future")===-1){q.classList.add("future");
}}else{if(u.length){q.classList.remove("past");q.classList.remove("future");}}}}}}});if(b.length===1){h=true;f();}}function a(p){for(var n=0;n<b.length;
n++){if(b[n].domElement==p){b.splice(n,1);n--;var l=Array.prototype.slice.apply(p.children);for(var m=0,k=l.length;m<k;m++){var o=l[m];o.classList.remove("past");
o.classList.remove("future");}}}if(b.length===0){h=false;}}function e(m){for(var l=0,k=b.length;l<k;l++){if(b[l].domElement==m){return true;}}return false;
}function d(){return !!document.body.classList;}function c(k,l){if(typeof k==="string"){var i=document.querySelectorAll(k);for(j=0;j<i.length;j++){l.call(null,i[j]);
}}else{if(typeof k==="object"&&typeof k.length==="number"){for(j=0;j<k.length;j++){l.call(null,k[j]);}}else{if(k.nodeName){l.call(null,k);}else{throw"Stroll target was of unexpected type.";
}}}}window.Stroll={bind:function(i){if(d()){c(i,g);}},unbind:function(i){if(d()){c(i,a);}}};})();window.requestAnimFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1000/60);
};})();
o.classList.remove("future");}}}if(b.length===0){h=false;}}function e(l){for(var k=0,j=b.length;k<j;k++){if(b[k].domElement==l){return true;}}return false;
}function c(m,n){var l,j;if(typeof m==="string"){var k=document.querySelectorAll(m);for(l=0,j=k.length;l<j;l++){n.call(null,k[l]);}}else{if(typeof m==="object"&&typeof m.length==="number"){for(l=0,j=m.length;
l<j;l++){n.call(null,m[l]);}}else{if(m.nodeName){n.call(null,m);}else{throw"Stroll target was of unexpected type.";}}}}function d(){return !!document.body.classList;
}window.Stroll={bind:function(i){if(d()){c(i,g);}},unbind:function(i){if(d()){c(i,a);}}};window.requestAnimFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(i){window.setTimeout(i,1000/60);
};})();})();

0 comments on commit 395a007

Please sign in to comment.