File tree Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "liveServer.settings.port" : 5501
3
+ }
Original file line number Diff line number Diff line change
1
+ .neptune-spin {
2
+ animation : spin 1s 0s infinite;
3
+ ani
4
+ }
5
+
6
+ @keyframes spin {
7
+ 100% { transform : rotate (360deg );}
8
+ }
9
+
10
+
11
+
12
+ .test {
13
+ margin : 15rem ;
14
+ width : 4rem ;
15
+ height : 4rem ;
16
+ background-color : aqua;
17
+ }
Original file line number Diff line number Diff line change
1
+ export default class NeptuneAnimate {
2
+ constructor ( element , animationClass ) {
3
+ this . element = element ;
4
+ this . animationClass = animationClass ;
5
+ this . animationEndEvent = this . getAnimationEndEvent ( ) ;
6
+
7
+ this . element . addEventListener ( this . animationEndEvent , this . handleAnimationEnd . bind ( this ) ) ;
8
+ }
9
+
10
+ getAnimationEndEvent ( ) {
11
+ const el = document . createElement ( "div" ) ;
12
+ const animations = {
13
+ animation : "animationend" ,
14
+ OAnimation : "oAnimationEnd" ,
15
+ MozAnimation : "animationend" ,
16
+ WebkitAnimation : "webkitAnimationEnd"
17
+ } ;
18
+
19
+ for ( const key in animations ) {
20
+ if ( el . style [ key ] !== undefined ) {
21
+ return animations [ key ] ;
22
+ }
23
+ }
24
+
25
+ return "animationend" ;
26
+ }
27
+
28
+ handleAnimationEnd ( ) {
29
+ this . element . classList . remove ( this . animationClass ) ;
30
+ this . element . removeEventListener ( this . animationEndEvent , this . handleAnimationEnd ) ;
31
+ }
32
+
33
+ startAnimation ( ) {
34
+ this . element . classList . add ( this . animationClass ) ;
35
+ }
36
+
37
+ stopAnimation ( ) {
38
+ this . element . classList . remove ( this . animationClass ) ;
39
+ }
40
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="de ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+
7
+ < link rel ="stylesheet " href ="../neptune-animations.css ">
8
+
9
+ < title > Document</ title >
10
+ </ head >
11
+ < body >
12
+ < div class ="test " id ="test "> </ div >
13
+
14
+ < script type ="module ">
15
+ import NeptuneAnimate from "../neptune-animations.js"
16
+
17
+ const myElement = document . getElementById ( "test" ) ;
18
+ const neptuneAnimate = new NeptuneAnimate ( myElement , "neptune-spin" ) ;
19
+
20
+ neptuneAnimate . startAnimation ( ) ;
21
+
22
+ setTimeout ( function ( ) {
23
+ neptuneAnimate . stopAnimation ( ) ;
24
+ } , 5000 ) ;
25
+ </ script >
26
+ </ body >
27
+ </ html >
You can’t perform that action at this time.
0 commit comments