Allow customizable flash showDuration and fadeDuration

This commit is contained in:
Bryan Housel
2017-02-15 22:28:19 -05:00
parent 028ef3de3f
commit b7a81c6bec
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -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();
}
});
+6 -3
View File
@@ -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;