Skip to content

Commit

Permalink
Linter and minor efficiency update
Browse files Browse the repository at this point in the history
Resolves #33
  • Loading branch information
samatcd authored Mar 18, 2017
1 parent 02039b8 commit 160ec4b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions jquery.visible.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@
* the user visible viewport of a web browser.
* only accounts for vertical position, not horizontal.
*/
var $w=$(window);
$.fn.visible = function(partial,hidden,direction,container){

if (this.length < 1)
return;


// Set direction default to 'both'.
direction = direction || 'both';

var $t = this.length > 1 ? this.eq(0) : this,
isContained = typeof container !== 'undefined' && container !== null,
$w = isContained ? $(container) : $(window),
wPosition = isContained ? $w.position() : 0,
$c = isContained ? $(container) : $w,
wPosition = isContained ? $c.position() : 0,
t = $t.get(0),
vpWidth = $w.outerWidth(),
vpHeight = $w.outerHeight(),
direction = (direction) ? direction : 'both',
vpWidth = $c.outerWidth(),
vpHeight = $c.outerHeight(),
clientSize = hidden === true ? t.offsetWidth * t.offsetHeight : true;

if (typeof t.getBoundingClientRect === 'function'){
Expand Down Expand Up @@ -56,7 +59,7 @@

var viewTop = isContained ? 0 : wPosition,
viewBottom = viewTop + vpHeight,
viewLeft = $w.scrollLeft(),
viewLeft = $c.scrollLeft(),
viewRight = viewLeft + vpWidth,
position = $t.position(),
_top = position.top,
Expand Down

0 comments on commit 160ec4b

Please sign in to comment.