Skip to content

Commit

Permalink
Added check for windows phone #19
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkgroenen committed Jul 15, 2015
1 parent 9be0333 commit efc0cae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jQuery-viewport-checker",
"version": "1.8.1",
"version": "1.8.2",
"homepage": "https://github.com/dirkgroenen/jQuery-viewport-checker",
"authors": [
"Dirk Groenen <dirk@bitlabs.nl>",
Expand All @@ -22,4 +22,4 @@
"test",
"tests"
]
}
}
4 changes: 2 additions & 2 deletions dist/jquery.viewportchecker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jquery.viewportchecker.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jQuery-viewport-checker",
"author": "Dirk Groenen",
"version": "1.8.1",
"version": "1.8.2",
"homepage": "https://github.com/dirkgroenen/jQuery-viewport-checker",
"description": "Little script that detects if an element is in the viewport and adds a class to it.",
"repository": "https://github.com/dirkgroenen/jQuery-viewport-checker",
Expand Down
19 changes: 14 additions & 5 deletions src/jquery.viewportchecker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Version 1.8.0
Version 1.8.2
The MIT License (MIT)
Copyright (c) 2014 Dirk Groenen
Expand Down Expand Up @@ -32,7 +32,7 @@
// Cache the given element and height of the browser
var $elem = this,
windowSize = {height: $(window).height(), width: $(window).width()},
scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') != -1) ? 'body' : 'html');
scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') != -1 || navigator.userAgent.toLowerCase().indexOf('windows phone') != -1) ? 'body' : 'html');

/*
* Main method that checks the elements and adds or removes the class(es)
Expand Down Expand Up @@ -112,9 +112,18 @@

};

// Run checkelements on load and scroll
$(document).bind("touchmove MSPointerMove pointermove", this.checkElements);
$(window).bind("load scroll touchmove", this.checkElements);
// Select the correct events
if( !!('ontouchstart' in window) ){
// Touchscreen
$(document).bind("touchmove MSPointerMove pointermove", this.checkElements);
}
else{
// No touchscreen
$(window).bind("scroll", this.checkElements);
}

// Always load on window load
$(window).bind("load", this.checkElements);

// On resize change the height var
$(window).resize(function(e){
Expand Down

0 comments on commit efc0cae

Please sign in to comment.