MCPcopy Create free account
hub / github.com/BloombergGraphics/whatiscode / updateFalling

Function updateFalling

modules/text-diff/text-diff.js:58–78  ·  view source on GitHub ↗
(curDiffIndex)

Source from the content-addressed store, hash-verified

56
57 var s = 1
58 function updateFalling(curDiffIndex){
59 var wordDiffs = diffToWords(diffs[curDiffIndex])
60
61 if (module.active){
62 d3.selectAll('#text-diff').html('')
63
64 d3.select('#text-diff').dataAppend(wordDiffs, 'div.falling')
65 .text(ƒ('value'))
66 .style('width', function(d){ return d.added ? '0.0px' : d.width })
67 .style('left', function(d){ return d.added ? '-2000px' : '0px' })
68 .transition().duration(0).delay(500*s)
69 .style('color', function(d){ return d.added ? 'green' : d.removed ? 'red' : '' })
70 .transition().duration(2000*s).delay(1000*s)
71 .style('width', function(d){ return d.removed ? '0.0px' : d.width })
72 .style('left', function(d){ return d.removed ? '2000px' : '0px' })
73
74 curDiffIndex = ++curDiffIndex % diffs.length
75 }
76
77 window.setTimeout(function(){ updateFalling(curDiffIndex) }, 5500)
78 }
79
80 updateFalling(3)
81

Callers 1

text-diff.jsFile · 0.85

Calls 1

diffToWordsFunction · 0.85

Tested by

no test coverage detected