@@ -33,8 +33,8 @@ const createFilter = (defs, id) => defs::append('filter')
3333 ::attr ( 'in' , 'SourceGraphic' )
3434 ::attr ( 'stdDeviation' , '0 0' ) ;
3535
36- const createGradient = ( defs ) => defs ::append ( 'linearGradient' )
37- ::attr ( 'id' , ' gradient' )
36+ const createGradient = ( defs , id ) => defs ::append ( 'linearGradient' )
37+ ::attr ( 'id' , ` gradient- ${ id } ` )
3838 ::attr ( 'x1' , '0%' )
3939 ::attr ( 'y1' , '0%' )
4040 ::attr ( 'x2' , '0%' )
@@ -43,30 +43,30 @@ const createGradient = (defs) => defs::append('linearGradient')
4343 ::attr ( 'offset' , '0' )
4444 ::attr ( 'stop-color' , 'white' )
4545 ::attr ( 'stop-opacity' , '0' )
46- ::select ( ' #gradient' )
46+ ::select ( ` #gradient- ${ id } ` )
4747 ::append ( 'stop' )
4848 ::attr ( 'offset' , '0.2' )
4949 ::attr ( 'stop-color' , 'white' )
5050 ::attr ( 'stop-opacity' , '1' )
51- ::select ( ' #gradient' )
51+ ::select ( ` #gradient- ${ id } ` )
5252 ::append ( 'stop' )
5353 ::attr ( 'offset' , '0.8' )
5454 ::attr ( 'stop-color' , 'white' )
5555 ::attr ( 'stop-opacity' , '1' )
56- ::select ( ' #gradient' )
56+ ::select ( ` #gradient- ${ id } ` )
5757 ::append ( 'stop' )
5858 ::attr ( 'offset' , '1' )
5959 ::attr ( 'stop-color' , 'white' )
6060 ::attr ( 'stop-opacity' , '0' ) ;
6161
62- const createMask = ( defs ) => defs ::append ( 'mask' )
63- ::attr ( 'id' , ' mask' )
62+ const createMask = ( defs , id ) => defs ::append ( 'mask' )
63+ ::attr ( 'id' , ` mask- ${ id } ` )
6464 ::append ( 'rect' )
6565 ::attr ( 'x' , 0 )
6666 ::attr ( 'y' , 0 )
6767 ::attr ( 'width' , '100%' )
6868 ::attr ( 'height' , '100%' )
69- ::attr ( 'fill' , ' url(#gradient)' ) ;
69+ ::attr ( 'fill' , ` url(#gradient- ${ id } )` ) ;
7070
7171const setViewBox = ( svg , width , height ) => svg
7272 ::attr ( 'width' , width )
@@ -87,22 +87,24 @@ export default ({
8787 const fontSize = parseInt ( computedStyle . fontSize , 10 ) ;
8888 const marginBottom = ( fontSize * lineHeight - fontSize ) / 2 + fontSize / 10 ;
8989 const offset = fontSize * lineHeight - marginBottom ;
90+ const salt = Date . now ( ) ;
9091
9192 let canvasWidth = 0 ;
9293 const canvasHeight = fontSize * lineHeight + marginBottom ;
9394
9495 element . innerHTML = '' ;
9596 const root = element ::append ( 'svg' ) ;
96- const svg = root ::append ( 'svg' ) ::attr ( 'mask' , ' url(#mask)' )
97+ const svg = root ::append ( 'svg' ) ::attr ( 'mask' , ` url(#mask- ${ salt } )` )
9798 const defs = root ::append ( 'defs' ) ;
98- createGradient ( defs ) ;
99- createMask ( defs ) ;
99+ createGradient ( defs , salt ) ;
100+ createMask ( defs , salt ) ;
100101
101102 const values = String ( value )
102103 . replace ( / / g, '\u00a0' )
103104 . split ( '' ) ;
104105
105106 const chars = values . map ( ( char , i ) => {
107+ const id = `${ i } -${ salt } ` ;
106108 if ( isNaN ( parseInt ( char , 10 ) ) ) {
107109 return {
108110 isDigit : false ,
@@ -113,9 +115,9 @@ export default ({
113115 } else {
114116 return {
115117 isDigit : true ,
116- id : i ,
117- node : createDigitRoulette ( svg , fontSize , lineHeight , i ) ,
118- filter : createFilter ( defs , i ) ,
118+ id : id ,
119+ node : createDigitRoulette ( svg , fontSize , lineHeight , id ) ,
120+ filter : createFilter ( defs , id ) ,
119121 value : Number ( char ) ,
120122 offset : { x : 0 , y : offset }
121123 } ;
0 commit comments