File tree 2 files changed +21
-9
lines changed
2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
function Granim ( options ) {
4
- if ( options . element instanceof HTMLCanvasElement )
5
- this . canvas = options . element
6
- else if ( typeof options . element === "string" )
7
- this . canvas = document . querySelector ( options . element )
8
- else
9
- throw new Error ( 'The element you used is neither a String, nor a HTMLCanvasElement' ) ;
10
- if ( ! this . canvas ) {
11
- throw new Error ( '`' + options . element + '` could not be found in the DOM' ) ;
12
- }
4
+ this . getElement ( options . element ) ;
13
5
this . x1 = 0 ;
14
6
this . y1 = 0 ;
15
7
this . name = options . name || false ;
@@ -22,6 +14,7 @@ function Granim(options) {
22
14
this . previousTimeStamp = null ;
23
15
this . progress = 0 ;
24
16
this . isPaused = false ;
17
+ this . isCleared = false ;
25
18
this . isPausedBecauseNotInView = false ;
26
19
this . iscurrentColorsSet = false ;
27
20
this . context = this . canvas . getContext ( '2d' ) ;
@@ -89,6 +82,8 @@ Granim.prototype.makeGradient = require('./makeGradient.js');
89
82
90
83
Granim . prototype . getDimensions = require ( './getDimensions.js' ) ;
91
84
85
+ Granim . prototype . getElement = require ( './getElement.js' ) ;
86
+
92
87
Granim . prototype . animateColors = require ( './animateColors.js' ) ;
93
88
94
89
Granim . prototype . getLightness = require ( './getLightness.js' ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ module . exports = function ( element ) {
4
+ if ( element instanceof HTMLCanvasElement ) {
5
+ this . canvas = element ;
6
+
7
+ } else if ( typeof element === "string" ) {
8
+ this . canvas = document . querySelector ( element ) ;
9
+
10
+ } else {
11
+ throw new Error ( 'The element you used is neither a String, nor a HTMLCanvasElement' ) ;
12
+ }
13
+
14
+ if ( ! this . canvas ) {
15
+ throw new Error ( '`' + element + '` could not be found in the DOM' ) ;
16
+ }
17
+ } ;
You can’t perform that action at this time.
0 commit comments