Skip to content

Commit

Permalink
Merge pull request #55 from pkostadinov-2create/patch-1
Browse files Browse the repository at this point in the history
Fix Viewport Checker
  • Loading branch information
dirkgroenen authored Sep 25, 2017
2 parents 42d1569 + a7f3776 commit 9ae92c7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/jquery.viewportchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

// Cache the given element and height of the browser
var $elem = this,
boxSize = {height: $(options.scrollBox).height(), width: $(options.scrollBox).width()},
scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') != -1 || navigator.userAgent.toLowerCase().indexOf('windows phone') != -1) ? 'body' : 'html');
boxSize = {height: $(options.scrollBox).height(), width: $(options.scrollBox).width()};

/*
* Main method that checks the elements and adds or removes the class(es)
Expand All @@ -44,11 +43,19 @@

// Set some vars to check with
if (!options.scrollHorizontal){
viewportStart = $(scrollElem).scrollTop();
viewportStart = Math.max(
$('html').scrollTop(),
$('body').scrollTop(),
$(window).scrollTop()
);
viewportEnd = (viewportStart + boxSize.height);
}
else{
viewportStart = $(scrollElem).scrollLeft();
viewportStart = Math.max(
$('html').scrollLeft(),
$('body').scrollLeft(),
$(window).scrollLeft()
);
viewportEnd = (viewportStart + boxSize.width);
}

Expand Down

0 comments on commit 9ae92c7

Please sign in to comment.