Created
March 1, 2016 14:57
-
-
Save leepettijohn/df4aa73fd2db6a9e18b8 to your computer and use it in GitHub Desktop.
Select items not on the screen or only partially visible
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
| // onScreen jQuery plugin v0.2.1 | |
| // (c) 2011-2013 Ben Pickles | |
| // | |
| // http://benpickles.github.io/onScreen | |
| // | |
| // Released under MIT license. | |
| ;(function($) { | |
| $.expr[":"].onScreen = function(elem) { | |
| var $window = $(window) | |
| var viewport_top = $window.scrollTop() | |
| var viewport_height = $window.height() | |
| var viewport_bottom = viewport_top + viewport_height | |
| var $elem = $(elem) | |
| var top = $elem.offset().top | |
| var height = $elem.height() | |
| var bottom = top + height | |
| return (top >= viewport_top && bottom < viewport_bottom) | |
| } | |
| })(jQuery); | |
| $('.twine-item:not(:onScreen)').css('display','none'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment