Added mobile detection and auto-scrolling when on mobile.

This commit is contained in:
Douglas Muth 2015-04-26 17:20:56 -04:00
parent 2b0e6b2c49
commit 88b36faca7
2 changed files with 24 additions and 0 deletions

View file

@ -92,6 +92,8 @@
<div class="row">
<div class="col-md-12">
<a name="roll_dice_button" ></a>
<h2>
Number of Dice to roll:
</h2>

22
main.js
View file

@ -110,12 +110,34 @@ function display_results() {
} // End of display_results()
/**
* Return true if we are running on a mobile screen.
*/
function is_mobile() {
if (jQuery(window).width() < 480) {
return(true);
}
return(false);
} // End of is_mobile()
//
// Handler when the "Roll Dice" button is clicked. It gets the
// passphrase and updates the HTML with it.
//
jQuery("#roll_dice").on("click", function(e) {
//
// If we're running on an iPhone or similar, scroll down so that we can
// see the dice rolls and passphrase.
//
if (is_mobile()) {
location.hash = "#roll_dice_button";
}
//
// Remove any old results
//