File tree 4 files changed +28
-7
lines changed
4 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ <h1>Oh dear!</h1>
18
18
>
19
19
</ canvas >
20
20
21
- < div id ="constant-force-panel " class ="panel panel-closed ">
21
+ < div id ="constant-force-panel " class ="panel panel-closed hide ">
22
22
< div class ="panel-header ">
23
23
< h2 > Constant force</ h2 >
24
24
< button type ="button " class ="delete "> Delete</ button >
@@ -36,7 +36,7 @@ <h2>Constant force</h2>
36
36
< button class ="close " type ="button "> Close</ button >
37
37
</ div >
38
38
39
- < div id ="radial-force-panel " class ="panel panel-closed ">
39
+ < div id ="radial-force-panel " class ="panel panel-closed hide ">
40
40
< div class ="panel-header ">
41
41
< h2 > Radial force</ h2 >
42
42
< button type ="button " class ="delete "> Delete</ button >
@@ -50,7 +50,7 @@ <h2>Radial force</h2>
50
50
< button class ="close " type ="button "> Close</ button >
51
51
</ div >
52
52
53
- < div id ="emitter-panel " class ="panel panel-closed ">
53
+ < div id ="emitter-panel " class ="panel panel-closed hide ">
54
54
< div class ="panel-header ">
55
55
< h2 > Emitter</ h2 >
56
56
< button type ="button " class ="delete "> Delete</ button >
@@ -104,4 +104,4 @@ <h2>Keyboard controls</h2>
104
104
105
105
< script src ="js/main.js " type ="module "> </ script >
106
106
</ body >
107
- </ html >
107
+ </ html >
Original file line number Diff line number Diff line change
1
+ export function onTransitionEnd ( el , fn ) {
2
+ if ( ! ( 'ontransitionend' in el ) ) {
3
+ fn ( ) ;
4
+ return ;
5
+ }
6
+ const listener = function ( event ) {
7
+ fn ( event ) ;
8
+ el . removeEventListener ( listener ) ;
9
+ } ;
10
+
11
+ el . addEventListener ( 'transitionend' , listener ) ;
12
+ }
13
+
14
+ export const rAF = requestAnimationFrame ;
Original file line number Diff line number Diff line change 1
1
import bindEvents from './bind-events.js' ;
2
+ import { onTransitionEnd , rAF } from './animation.js' ;
2
3
3
4
function sensiblePrecision ( number ) {
4
5
number = Number ( number ) ;
@@ -60,7 +61,8 @@ class Panel {
60
61
}
61
62
62
63
open ( item ) {
63
- this . el . classList . toggle ( 'panel-closed' , false ) ;
64
+ this . el . classList . remove ( 'hide' ) ;
65
+ rAF ( ( ) => this . el . classList . remove ( 'panel-closed' ) ) ;
64
66
this . item = item ;
65
67
for ( const setting of this . settings ) {
66
68
setting . inputEl . value = item [ setting . attr ] ;
@@ -69,7 +71,8 @@ class Panel {
69
71
}
70
72
71
73
close ( ) {
72
- this . el . classList . toggle ( 'panel-closed' , true ) ;
74
+ this . el . classList . add ( 'panel-closed' ) ;
75
+ onTransitionEnd ( this . el , ( ) => this . el . classList . add ( 'hide' ) ) ;
73
76
this . item = null ;
74
77
}
75
78
Original file line number Diff line number Diff line change @@ -147,4 +147,8 @@ button:hover {
147
147
padding : .5em 1em ;
148
148
background-color : # c23 ;
149
149
color : white;
150
- }
150
+ }
151
+
152
+ .hide {
153
+ display : none;
154
+ }
You can’t perform that action at this time.
0 commit comments