Files
iD/modules/ui/flash.js
Bryan Housel 3fc36b66a9 Let D3 handle the delay rather than using setTimeout
This also fixes a race condition where it was possible to lose a flash
message that was created while the previous one was transitioning away.
2017-02-16 10:19:07 -05:00

31 lines
706 B
JavaScript

import * as d3 from 'd3';
export function uiFlash(showDuration, fadeDuration) {
showDuration = showDuration || 1500;
fadeDuration = fadeDuration || 250;
d3.select('#flash').selectAll('.content')
.interrupt();
var content = d3.select('#flash').selectAll('.content')
.data([0]);
content = content.enter()
.append('div')
.attr('class', 'content fillD')
.merge(content);
content
.transition()
.delay(showDuration)
.duration(fadeDuration)
.style('opacity', 0)
.style('transform', 'scaleY(.1)')
.on('interrupt end', function() {
content.remove();
});
return content;
}