/*!
* $.fn.isInWindow
*
* version 0.0.1 (2010/11/17)
* author: Takeshi Takatsudo (takazudo[at]gmail.com)
* license: MIT
* depends: jQuery 1.4.4
*/
(function($, undefined){ // start encapsulation
var $win = $(window);
$.fn.isAboveTheWindow = function(opitons){
var $el = this;
if($el.size()>1){
$.error('2 or more elements were thrown.');
return false;
}
var o = $.extend({
threshold: 0
},opitons);
return ($win.scrollTop() >= $el.offset().top + o.threshold + $el.innerHeight());
};
$.fn.isBelowTheWindow = function(options){
var $el = this;
if($el.size()>1){
$.error('2 or more elements were thrown.');
return false;
}
var o = $.extend({
threshold: 0
},options);
return $win.height() + $win.scrollTop() <= $el.offset().top - o.threshold;
};
$.fn.isInWindow = function(){
var $el = this;
return !$el.isAboveTheWindow() && !$el.isBelowTheWindow();
};
})(jQuery); // end encapsulation