File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,7 @@ const createTags = (input) => {
15
15
} ) ;
16
16
} ;
17
17
18
- const pickRandomTag = ( ) => {
19
- const tags = document . querySelectorAll ( ".tag" ) ;
18
+ const pickRandomTag = ( tags ) => {
20
19
return tags [ Math . floor ( Math . random ( ) * tags . length ) ] ;
21
20
} ;
22
21
@@ -25,9 +24,10 @@ const highlightTag = (tag) => tag.classList.add("highlight");
25
24
const unHighlightTag = ( tag ) => tag . classList . remove ( "highlight" ) ;
26
25
27
26
const randomSelect = ( ) => {
27
+ const tags = document . querySelectorAll ( ".tag" ) ;
28
28
const times = 30 ;
29
29
const interval = setInterval ( ( ) => {
30
- const randomTag = pickRandomTag ( ) ;
30
+ const randomTag = pickRandomTag ( tags ) ;
31
31
highlightTag ( randomTag ) ;
32
32
setTimeout ( ( ) => {
33
33
unHighlightTag ( randomTag ) ;
@@ -37,7 +37,7 @@ const randomSelect = () => {
37
37
setTimeout ( ( ) => {
38
38
clearInterval ( interval ) ;
39
39
setTimeout ( ( ) => {
40
- const randomTag = pickRandomTag ( ) ;
40
+ const randomTag = pickRandomTag ( tags ) ;
41
41
highlightTag ( randomTag ) ;
42
42
} , 100 ) ;
43
43
} , times * 100 ) ;
You can’t perform that action at this time.
0 commit comments