@@ -37,13 +37,18 @@ const EasyCoder_PP = {
37
37
case `dissolve` :
38
38
if ( compiler . nextTokenIs ( `to` ) ) {
39
39
value = compiler . getNextValue ( ) ;
40
+ let duration = EasyCoder_Value . constant ( `1.0` , false ) ;
41
+ if ( compiler . tokenIs ( `duration` ) ) {
42
+ duration = compiler . getNextValue ( ) ;
43
+ }
40
44
compiler . addCommand ( {
41
45
domain : `pp` ,
42
46
keyword : `pp` ,
43
47
lino,
44
48
action : `dissolve` ,
45
49
name : symbolRecord . name ,
46
- value
50
+ value,
51
+ duration
47
52
} ) ;
48
53
return true ;
49
54
}
@@ -165,12 +170,15 @@ const EasyCoder_PP = {
165
170
let symbolRecord ;
166
171
let element ;
167
172
let inner ;
173
+ let newInner ;
168
174
let container ;
175
+ let steps ;
169
176
let pp ;
170
177
let values ;
171
178
let value ;
172
179
let w ;
173
180
let h ;
181
+ let n ;
174
182
const nConst = ( content ) => {
175
183
return {
176
184
type : `constant` ,
@@ -194,6 +202,18 @@ const EasyCoder_PP = {
194
202
* program . getValue ( defaults . aspectH ) / program . getValue ( defaults . aspectW ) ;
195
203
container . style [ `height` ] = `${ Math . round ( height ) } px` ;
196
204
} ;
205
+ const step = ( n , then ) => {
206
+ const opacity = parseFloat ( n ) / steps ;
207
+ newInner . style [ `opacity` ] = opacity ;
208
+ inner . style [ `opacity` ] = 1.0 - opacity ;
209
+ if ( n < steps ) {
210
+ setTimeout ( function ( ) {
211
+ step ( n + 1 , then ) ;
212
+ } , 100 ) ;
213
+ } else {
214
+ then ( ) ;
215
+ }
216
+ } ;
197
217
switch ( action ) {
198
218
case `attachDiv` :
199
219
symbolRecord = program . getSymbolRecord ( command . container ) ;
@@ -290,6 +310,7 @@ const EasyCoder_PP = {
290
310
element . style [ `border` ] = `${ program . getValue ( values . panelBorder ) } ` ;
291
311
container . appendChild ( element ) ;
292
312
inner = document . createElement ( `div` ) ;
313
+ inner . style [ `position` ] = `absolute` ;
293
314
inner . style [ `margin` ] = `${ program . getValue ( values . panelPadding ) } ` ;
294
315
inner . style [ `font-face` ] = program . getValue ( values . fontFace ) ;
295
316
inner . style [ `font-size` ] = `${ program . getValue ( values . fontSize ) * h / 1000 } px` ;
@@ -310,7 +331,24 @@ const EasyCoder_PP = {
310
331
symbolRecord = program . getSymbolRecord ( command . name ) ;
311
332
element = symbolRecord . element [ symbolRecord . index ] ;
312
333
value = program . getValue ( command . value ) ;
313
- element . inner . innerHTML = value . split ( `\n` ) . join ( `<br>` ) ;
334
+ steps = Math . round ( parseFloat ( program . getValue ( command . duration ) ) * 10 ) ;
335
+ inner = element . inner ;
336
+ newInner = document . createElement ( `div` ) ;
337
+ newInner . style [ `position` ] = `absolute` ;
338
+ newInner . style [ `margin` ] = inner . style [ `margin` ] ;
339
+ newInner . style [ `font-face` ] = inner . style [ `font-face` ] ;
340
+ newInner . style [ `font-size` ] = inner . style [ `font-size` ] ;
341
+ newInner . style [ `font-weight` ] = inner . style [ `font-weight` ] ;
342
+ newInner . style [ `font-style` ] = inner . style [ `font-style` ] ;
343
+ newInner . style [ `color` ] = inner . style [ `color` ] ;
344
+ newInner . style [ `text-align` ] = inner . style [ `text-align` ] ;
345
+ newInner . innerHTML = value . split ( `\n` ) . join ( `<br>` ) ;
346
+ element . appendChild ( newInner ) ;
347
+ step ( 0 , function ( ) {
348
+ inner . innerHTML = newInner . innerHTML ;
349
+ inner . style [ `opacity` ] = 1.0 ;
350
+ element . removeChild ( newInner ) ;
351
+ } ) ;
314
352
break ;
315
353
}
316
354
return command . pc + 1 ;
0 commit comments