@@ -61,20 +61,25 @@ export function useTransition(
61
61
backward : boolean ,
62
62
codeConfig : CodeConfig
63
63
) : Transition {
64
+ // prevSnapshot has the dimensions of the editor for t=0
65
+ // nextSnapshot has the dimensions of the editor for t=1
64
66
const { prevSnapshot, nextSnapshot } = useSnapshots (
65
67
ref ,
66
68
prev ,
67
69
next
68
70
)
69
71
72
+ // we return the default styles for t=0 until we measure the dimensions
70
73
if ( ! prevSnapshot ) {
71
74
return startingPosition ( prev , next , codeConfig )
72
75
}
73
76
77
+ // and the same for t=1
74
78
if ( ! nextSnapshot ) {
75
79
return endingPosition ( prev , next , codeConfig )
76
80
}
77
81
82
+ // TODO this should be commented
78
83
// if (t === 0) {
79
84
// return startingPosition(prev, next, codeConfig)
80
85
// }
@@ -114,7 +119,10 @@ export function useTransition(
114
119
prevFile = { prevNorthFile }
115
120
nextFile = { nextNorthFile }
116
121
t = { t }
117
- parentHeight = { northStyle . height as string }
122
+ parentHeight = {
123
+ ( northStyle . height ||
124
+ northStyle . minHeight ) as string
125
+ }
118
126
/>
119
127
) ,
120
128
} ,
@@ -127,7 +135,10 @@ export function useTransition(
127
135
prevFile = { prevSouthFile ! }
128
136
nextFile = { nextSouthFile ! }
129
137
t = { t }
130
- parentHeight = { southStyle ?. height as string }
138
+ parentHeight = {
139
+ ( southStyle ?. height ||
140
+ southStyle ?. minHeight ) as string
141
+ }
131
142
/>
132
143
) ,
133
144
} ,
@@ -150,12 +161,6 @@ function startingPosition(
150
161
nextSouthFile,
151
162
} = getStepFiles ( prev , next , true )
152
163
153
- const northHeight = inputSouthPanel
154
- ? `calc((100% - var(--ch-title-bar-height)) * ${ inputNorthPanel . heightRatio } )`
155
- : "100%"
156
-
157
- const southHeight = `calc((100% - var(--ch-title-bar-height)) * ${ inputSouthPanel ?. heightRatio } + var(--ch-title-bar-height))`
158
-
159
164
return {
160
165
northPanel : {
161
166
tabs : inputNorthPanel . tabs . map ( title => ( {
@@ -164,15 +169,16 @@ function startingPosition(
164
169
style : { } ,
165
170
} ) ) ,
166
171
style : {
167
- height : northHeight ,
172
+ flexGrow : 1 ,
173
+ overflow : "hidden" ,
168
174
} ,
169
175
children : (
170
176
< CodeTransition
171
177
codeConfig = { codeConfig }
172
178
prevFile = { prevNorthFile }
173
- nextFile = { nextNorthFile }
179
+ nextFile = { prevNorthFile }
174
180
t = { 0 }
175
- parentHeight = { northHeight }
181
+ parentHeight = { "0" }
176
182
/>
177
183
) ,
178
184
} ,
@@ -183,15 +189,16 @@ function startingPosition(
183
189
style : { } ,
184
190
} ) ) ,
185
191
style : {
186
- height : `calc((100% - var(--ch-title-bar-height)) * ${ inputSouthPanel . heightRatio } + var(--ch-title-bar-height))` ,
192
+ flexGrow : 1 ,
193
+ overflow : "hidden" ,
187
194
} ,
188
195
children : (
189
196
< CodeTransition
190
197
codeConfig = { codeConfig }
191
198
prevFile = { prevSouthFile ! }
192
- nextFile = { nextSouthFile ! }
199
+ nextFile = { prevSouthFile ! }
193
200
t = { 0 }
194
- parentHeight = { southHeight }
201
+ parentHeight = { "0" }
195
202
/>
196
203
) ,
197
204
} ,
@@ -221,12 +228,6 @@ function endingPosition(
221
228
nextNorthFile = nextSouthFile !
222
229
}
223
230
224
- const northHeight = inputSouthPanel
225
- ? `calc((100% - var(--ch-title-bar-height)) * ${ inputNorthPanel . heightRatio } )`
226
- : "100%"
227
-
228
- const southHeight = `calc((100% - var(--ch-title-bar-height)) * ${ inputSouthPanel ?. heightRatio } + var(--ch-title-bar-height))`
229
-
230
231
return {
231
232
northPanel : {
232
233
tabs : inputNorthPanel . tabs . map ( title => ( {
@@ -235,15 +236,16 @@ function endingPosition(
235
236
style : { } ,
236
237
} ) ) ,
237
238
style : {
238
- height : northHeight ,
239
+ flexGrow : 1 ,
240
+ overflow : "hidden" ,
239
241
} ,
240
242
children : (
241
243
< CodeTransition
242
244
codeConfig = { codeConfig }
243
- prevFile = { prevNorthFile }
245
+ prevFile = { nextNorthFile }
244
246
nextFile = { nextNorthFile }
245
247
t = { 1 }
246
- parentHeight = { northHeight }
248
+ parentHeight = { "1" }
247
249
/>
248
250
) ,
249
251
} ,
@@ -254,15 +256,16 @@ function endingPosition(
254
256
style : { } ,
255
257
} ) ) ,
256
258
style : {
257
- height : southHeight ,
259
+ flexGrow : 1 ,
260
+ overflow : "hidden" ,
258
261
} ,
259
262
children : (
260
263
< CodeTransition
261
264
codeConfig = { codeConfig }
262
- prevFile = { prevSouthFile ! }
265
+ prevFile = { nextSouthFile ! }
263
266
nextFile = { nextSouthFile ! }
264
267
t = { 1 }
265
- parentHeight = { southHeight }
268
+ parentHeight = { "1" }
266
269
/>
267
270
) ,
268
271
} ,
@@ -285,7 +288,7 @@ function CodeTransition({
285
288
const htmlProps = {
286
289
...codeConfig ?. htmlProps ,
287
290
style : {
288
- height : "unset " ,
291
+ height : "100% " ,
289
292
...codeConfig ?. htmlProps ?. style ,
290
293
} ,
291
294
}
@@ -403,7 +406,7 @@ function getPanelStyles(
403
406
) {
404
407
return {
405
408
northStyle : {
406
- height : prev . northHeight ,
409
+ minHeight : prev . northHeight ,
407
410
} ,
408
411
}
409
412
}
@@ -420,14 +423,14 @@ function getPanelStyles(
420
423
) {
421
424
return {
422
425
northStyle : {
423
- height : tween (
426
+ minHeight : tween (
424
427
prev . northHeight ,
425
428
next . northHeight ,
426
429
t
427
430
) ,
428
431
} ,
429
432
southStyle : {
430
- height : prev . southHeight ,
433
+ minHeight : prev . southHeight ,
431
434
} ,
432
435
}
433
436
}
@@ -444,13 +447,13 @@ function getPanelStyles(
444
447
) {
445
448
return {
446
449
northStyle : {
447
- height : prev . northHeight ,
450
+ minHeight : prev . northHeight ,
448
451
} ,
449
452
southStyle : {
450
453
position : "relative" ,
451
- height : tween (
454
+ minHeight : tween (
452
455
prev . southHeight ,
453
- next . northHeight + next . titleBarHeight ,
456
+ next . northHeight ,
454
457
t
455
458
) ,
456
459
transform : `translateY(${ tween (
@@ -474,15 +477,15 @@ function getPanelStyles(
474
477
) {
475
478
return {
476
479
northStyle : {
477
- height : tween (
480
+ minHeight : tween (
478
481
prev . northHeight ,
479
482
next . northHeight ,
480
483
t
481
484
) ,
482
485
} ,
483
486
southStyle : {
484
487
position : "relative" ,
485
- height : next . southHeight ! ,
488
+ minHeight : next . southHeight ! ,
486
489
} ,
487
490
}
488
491
}
@@ -499,12 +502,12 @@ function getPanelStyles(
499
502
) {
500
503
return {
501
504
northStyle : {
502
- height : next . northHeight ,
505
+ minHeight : next . northHeight ,
503
506
} ,
504
507
southStyle : {
505
508
position : "relative" ,
506
- height : tween (
507
- prev . northHeight + prev . titleBarHeight ,
509
+ minHeight : tween (
510
+ prev . northHeight ,
508
511
next . southHeight ! ,
509
512
t
510
513
) ,
@@ -524,10 +527,14 @@ function getPanelStyles(
524
527
// +---+---+
525
528
return {
526
529
northStyle : {
527
- height : tween ( prev . northHeight , next . northHeight , t ) ,
530
+ minHeight : tween (
531
+ prev . northHeight ,
532
+ next . northHeight ,
533
+ t
534
+ ) ,
528
535
} ,
529
536
southStyle : {
530
- height : tween (
537
+ minHeight : tween (
531
538
prev . southHeight ! ,
532
539
next . southHeight ! ,
533
540
t
@@ -775,6 +782,7 @@ function useSnapshots(
775
782
776
783
useLayoutEffect ( ( ) => {
777
784
if ( ! prevSnapshot ) {
785
+ // debugger
778
786
setState ( s => ( {
779
787
...s ,
780
788
prevSnapshot : {
@@ -783,6 +791,7 @@ function useSnapshots(
783
791
} ,
784
792
} ) )
785
793
} else if ( ! nextSnapshot ) {
794
+ // debugger
786
795
setState ( s => ( {
787
796
...s ,
788
797
nextSnapshot : {
0 commit comments