From 88b36faca762cab859f26f1b3da21bbe210f349f Mon Sep 17 00:00:00 2001 From: Douglas Muth Date: Sun, 26 Apr 2015 17:20:56 -0400 Subject: [PATCH] Added mobile detection and auto-scrolling when on mobile. --- index.html | 2 ++ main.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/index.html b/index.html index 17dca36..5a43538 100644 --- a/index.html +++ b/index.html @@ -92,6 +92,8 @@
+ +

Number of Dice to roll:

diff --git a/main.js b/main.js index 747f8ae..fb028d8 100644 --- a/main.js +++ b/main.js @@ -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 //