Repository navigation
Expand file tree
/
Copy pathNoticeContainer.js
More file actions
49 lines (45 loc) · 1.85 KB
/
Copy pathNoticeContainer.js
File metadata and controls
49 lines (45 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { useEffect, useRef } from 'react';
import {Icon} from 'semantic-ui-react';
export default function NoticeContainer() {
const listEl = useRef(null);
useSliderEffect(listEl);
return (
<div className='notice-container' ref={listEl}>
<a className='animated fadeIn show' target='_blank' rel='noopener noreferrer'
href='https://github.com/unbug/snts'>
<Icon name='heartbeat'/> SAY NO TO SUICIDE PUBLIC LICENSE
</a>
<a className='animated fadeIn' target='_blank' rel='noopener noreferrer' href='//mihtool.com/'>
<Icon name='code'/> [MIHTool] iOS 上调试和优化页面的工具
</a>
<a className='animated fadeIn' target='_blank' rel='noopener noreferrer' href='https://www.wasmrocks.com/'>
<Icon name='hand rock'/> WebAssembly Rocks
</a>
<a className='animated fadeIn' target='_blank' rel='noopener noreferrer'
href='https://github.com/unbug/react-native-train/blob/master/README.md'>
<Icon name='video'/> [开源] React Native 开发培训资料和视频
</a>
<a className='animated fadeIn' target='_blank' rel='noopener noreferrer'
href='https://www.zhihu.com/question/27097399/answer/78619944'>
[知乎] 编程的时候命名方法或变量词穷了怎么办?
</a>
</div>
)
}
function useSliderEffect(el) {
useEffect(() => {
const timer = setInterval(() => renderItem(el.current.children), 10000);
return () => clearInterval(timer);
}, []); // run an effect and clean it up only once (on mount and unmount), you can pass an empty array ([])
let active = 1;
function renderItem(list) {
Array.prototype.forEach.call(list, (item, i) => {
if (i === active) {
item.classList.add('show');
} else {
item.classList.remove('show');
}
});
active = (active + 1) % list.length;
}
}