Files
iD/modules/ui/flash.js
Bryan Housel c18cc7577d Add flash test, avoid using sinon.useFakeTimers in tests.
sinon.useFakeTimers mocks setInterval, setTimeout, etc,
but not requestAnimationFrame, which d3 transitions rely on.
2017-02-11 00:19:49 -05:00

36 lines
705 B
JavaScript

import * as d3 from 'd3';
var timeout;
export function uiFlash() {
var content = d3.select('#flash').selectAll('.content')
.data([0]);
content = content.enter()
.append('div')
.attr('class', 'content fillD')
.merge(content);
if (timeout) {
window.clearTimeout(timeout);
}
timeout = window.setTimeout(function() {
content
.transition()
.duration(250)
.style('opacity', 0)
.style('transform', 'scaleY(.1)')
.on('end', function() {
content.remove();
timeout = null;
});
return true;
}, 1500);
return content;
}