From 84d77e39019ba8e0d3bc9b93b731290c8f3d8b0c Mon Sep 17 00:00:00 2001 From: Douglas Muth Date: Tue, 10 Nov 2015 23:39:31 -0500 Subject: [PATCH] Started reducing the delay of subsequent dice rolls. It speeds up the rolling of 8 dice. --- main.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index fe3aebf..ab836ac 100644 --- a/main.js +++ b/main.js @@ -93,13 +93,14 @@ jQuery(".dice_button").on("click", function(e) { * * @param array rows Array of rows of dice rolls that we had. * @param object cb Our callback to fire when done +* @param integer in_fadein_duration How long before fading in a roll of dice +* @param integer in_fadeout_delay How long before fading out the diceroll * */ -function display_row(rows, cb) { +function display_row(rows, cb, in_fadein_duration, in_fadeout_delay) { - var fadein_duration = 250; - var fadeout_delay = 750; -console.log(rows.length, fadein_duration, fadeout_delay); + var fadein_duration = in_fadein_duration || 250; + var fadeout_delay = in_fadeout_delay || 750; if (rows.length) { // @@ -125,13 +126,21 @@ console.log(rows.length, fadein_duration, fadeout_delay); }); + // + // Decrease the delays with subsequent rolls so that users + // don't get impatent. + // (I know I did when rolling 8 dice!) + // + fadein_duration -= 25; + fadeout_delay -= 50; + // // Now fade out the entire row, and call ourselves again // so we can repeat with the next row. // jQuery(this).delay(fadeout_delay) .fadeOut(fadeout_delay, function() { - display_row(rows, cb); + display_row(rows, cb, fadein_duration, fadeout_delay); }); });