This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @desc checks if current element is on screen or within viewport | |
* @param none | |
* @return int - the coordinates of the window vs. the element | |
*/ | |
jQuery.fn.isOnScreen = function(){ | |
var win = $(window); | |
var viewport = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @desc checks if current element exists | |
* @param none | |
* @return int - the number of elements present, > 0 = element exists | |
*/ | |
jQuery.fn.exists = function(){ return this.length > 0; } | |
// Usage: | |
if( $('#my-div').exists() ){ | |
// do something |
NewerOlder