return element in viewport

$.returnInView = function(el) { var $this = $(el), _elHeight = parseInt($this.outerHeight() * 0.5, 10), _elTop = $this.offset().top, _scrollTop = document.documentElement.scrollTop || document.body.scrollTop, _winHeight = $window.height(), _winInnerHeight = (window.innerHeight && window.innerHeight < _winHeight) ? window.innerHeight : _winHeight, _result = (_elTop + _elHeight) > _scrollTop && (_elHeight + _elTop) < (_scrollTop + _winInnerHeight); return _result; };

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.