From b7a81c6becf45c4c0fa645bc8ded56641b57396f Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 15 Feb 2017 22:28:19 -0500 Subject: [PATCH] Allow customizable flash showDuration and fadeDuration --- modules/behavior/operation.js | 4 ++-- modules/ui/flash.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/behavior/operation.js b/modules/behavior/operation.js index 804a5b7d9..f397460d3 100644 --- a/modules/behavior/operation.js +++ b/modules/behavior/operation.js @@ -15,10 +15,10 @@ export function behaviorOperation(context) { d3.event.preventDefault(); var disabled = which.disabled(); if (disabled) { - uiFlash().text(which.tooltip); + uiFlash(2000, 500).text(which.tooltip); } else { var annotation = which.annotation || which.title; - uiFlash().text(annotation); + uiFlash(1500, 250).text(annotation); which(); } }); diff --git a/modules/ui/flash.js b/modules/ui/flash.js index ee7f4d249..d4dc40cfe 100644 --- a/modules/ui/flash.js +++ b/modules/ui/flash.js @@ -3,7 +3,10 @@ import * as d3 from 'd3'; var timeout; -export function uiFlash() { +export function uiFlash(showDuration, fadeDuration) { + showDuration = showDuration || 1500; + fadeDuration = fadeDuration || 250; + var content = d3.select('#flash').selectAll('.content') .data([0]); @@ -19,7 +22,7 @@ export function uiFlash() { timeout = window.setTimeout(function() { content .transition() - .duration(250) + .duration(fadeDuration) .style('opacity', 0) .style('transform', 'scaleY(.1)') .on('end', function() { @@ -28,7 +31,7 @@ export function uiFlash() { }); return true; - }, 1500); + }, showDuration); return content;