8000 Preloader on SaffronCode · SaffronCode/SaffronCodeJS@4fc740f · GitHub
[go: up one dir, main page]

Skip to content 8000
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 4fc740f

Browse files
committed
Preloader on SaffronCode
1 parent c942512 commit 4fc740f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66

77
# production
88
d# misc
9-
node_modules
9+
node_modules
10+
lib

src/SaffronCode.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import Preloader from './ui/PreLoader'
2+
13
var SaffronCode = {};
24

5+
SaffronCode.Preloader = Preloader;
6+
37
export default SaffronCode ;

src/ui/PreLoader.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ export default class Preloader extends Component {
1616
preLoaderColor = newColor ;
1717
}
1818

19-
componentDidMount() {
19+
onCanvasCreated(canvas) {
2020
//Start animation
2121
/**@type {canvas} */
2222
this.rad = 0 ;
23-
this.ctx = this.refs.canvas.getContext('2d');
23+
this.ctx = canvas.getContext('2d');
2424

25+
this.animate();
2526
this.intervalId = setInterval(this.animate.bind(this),10);
2627
}
2728
componentWillUnmount(){
@@ -49,7 +50,7 @@ export default class Preloader extends Component {
4950

5051
render() {
5152
return (
52-
<canvas style={{width:100,height:100,margin:'auto',display:'block'}} ref="canvas" width={Width} height={Height}/>
53+
<canvas style={{width:100,height:100,margin:'auto',display:'block'}} ref={this.onCanvasCreated.bind(this)} width={Width} height={Height}/>
5354
);
5455
}
5556
};

0 commit comments

Comments
 (0)
0