All Downloads are FREE. Search and download functionalities are using the official Maven repository.

www.js.plugins.jquery.isOnScreen.js Maven / Gradle / Ivy

There is a newer version: 3.8.2.9
Show newest version
// Generated by CoffeeScript 1.5.0
(function() {

  $.fn.isOnScreen = function(scrollTop, scrollLeft, windowWidth, windowHeight) {
    var boundsBottom, boundsLeft, boundsRight, boundsTop, isVisible, scrollBottom, scrollRight;
    scrollRight = scrollLeft + windowWidth;
    scrollBottom = scrollTop + windowHeight;
    boundsLeft = this[0].offsetLeft;
    boundsTop = this[0].offsetTop;
    if (scrollRight < boundsLeft || scrollBottom < boundsTop) {
      return false;
    }
    isVisible = this.is(':visible');
    if (isVisible) {
      boundsRight = boundsLeft + this[0].offsetWidth;
    } else {
      boundsRight = boundsLeft;
    }
    if (scrollLeft > boundsRight) {
      return false;
    }
    if (isVisible) {
      boundsBottom = boundsTop + this[0].offsetHeight;
    } else {
      boundsBottom = boundsTop;
    }
    if (scrollTop > boundsBottom) {
      return false;
    }
    return true;
  };

}).call(this);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy