@@ -80,10 +80,10 @@ const EasyCoder_VFX = {
80
80
const lino = compiler . getLino ( ) ;
81
81
const action = compiler . nextToken ( ) ;
82
82
switch ( action ) {
83
- case `trigger` :
84
- if ( compiler . nextIsSymbol ( ) ) {
85
- let symbolRecord = compiler . getSymbolRecord ( ) ;
86
- if ( symbolRecord . keyword === `animation` ) {
83
+ case `trigger` :
84
+ if ( compiler . nextIsSymbol ( ) ) {
85
+ let symbolRecord = compiler . getSymbolRecord ( ) ;
86
+ if ( symbolRecord . keyword === `animation` ) {
87
87
compiler . next ( ) ;
88
88
compiler . addCommand ( {
89
89
domain : `vfx` ,
@@ -152,67 +152,68 @@ const EasyCoder_VFX = {
152
152
let container = targetRecord . element [ targetRecord . index ] ;
153
153
let animation ;
154
154
switch ( command . type ) {
155
- case `url` :
156
- let url = program . getValue ( command . value ) ;
157
- animation . image . setAttribute ( `src` , url ) ;
158
- break ;
159
- case `specification` :
160
- case `spec` :
161
- animation = targetRecord . animation [ targetRecord . index ] ;
162
- let spec = JSON . parse ( program . getValue ( command . value ) ) ;
163
- animation . spec = spec ;
164
- animation . step = spec . steps ;
165
- if ( [ ' panzoom' ] . includes ( spec . type ) ) {
166
- container . style . width = spec . width ;
167
- container . style . height = spec . height ;
168
- let width = container . getBoundingClientRect ( ) . width ;
169
- let height = container . getBoundingClientRect ( ) . height ;
170
- animation . widthS = width * 100 / spec . start . width ;
171
- let zoomS = animation . widthS / width ;
172
- let heightS = height * zoomS ;
173
- animation . leftS = width * zoomS * spec . start . left / 100 ;
174
- animation . topS = height * zoomS * spec . start . top / 100 ;
175
- animation . widthF = width * 100 / spec . finish . width ;
176
- let zoomF = animation . widthF / width ;
177
- let heightF = height * zoomF ;
178
- animation . leftF = width * zoomF * spec . finish . left / 100 ;
179
- animation . topF = height * zoomF * spec . finish . top / 100 ;
155
+ case `url` :
156
+ let url = program . getValue ( command . value ) ;
157
+ animation . image . setAttribute ( `src` , url ) ;
158
+ break ;
159
+ case `specification` :
160
+ case `spec` :
161
+ animation = targetRecord . animation [ targetRecord . index ] ;
162
+ let spec = JSON . parse ( program . getValue ( command . value ) ) ;
163
+ animation . spec = spec ;
164
+ animation . step = spec . steps ;
165
+ if ( [ ` panzoom` ] . includes ( spec . type ) ) {
166
+ container . style . width = spec . width ;
167
+ container . style . height = spec . height ;
168
+ let width = container . getBoundingClientRect ( ) . width ;
169
+ let height = container . getBoundingClientRect ( ) . height ;
170
+ animation . widthS = width * 100 / spec . start . width ;
171
+ let zoomS = animation . widthS / width ;
172
+ let heightS = height * zoomS ;
173
+ animation . leftS = width * zoomS * spec . start . left / 100 ;
174
+ animation . topS = height * zoomS * spec . start . top / 100 ;
175
+ animation . widthF = width * 100 / spec . finish . width ;
176
+ let zoomF = animation . widthF / width ;
177
+ let heightF = height * zoomF ;
178
+ animation . leftF = width * zoomF * spec . finish . left / 100 ;
179
+ animation . topF = height * zoomF * spec . finish . top / 100 ;
180
180
181
- if ( spec . start . width > 100 ) {
182
- throw new Error ( `Start width too great for item ${ targetRecord . index } ` ) ;
183
- }
184
- if ( spec . finish . width > 100 ) {
185
- throw new Error ( `Finish width too great for item ${ targetRecord . index } ` ) ;
186
- }
187
- if ( animation . widthS - animation . leftS < width ) {
188
- throw new Error ( `Insufficient start width for item ${ targetRecord . index } ` ) ;
189
- }
190
- if ( heightS - animation . topS < height ) {
191
- throw new Error ( `Insufficient start height for item ${ targetRecord . index } ` ) ;
192
- }
193
- if ( animation . widthF - animation . leftF < width ) {
194
- throw new Error ( `Insufficient finish width for item ${ targetRecord . index } ` ) ;
195
- }
196
- if ( heightF - animation . topF < height ) {
197
- throw new Error ( `Insufficient finish height for item ${ targetRecord . index } ` ) ;
198
- }
199
- animation . left = animation . leftS ;
200
- animation . top = animation . topS ;
201
- animation . width = animation . widthS ;
202
- let image = animation . image ;
203
- image . style . left = `-${ animation . left } px` ;
204
- image . style . top = `-${ animation . top } px` ;
205
- image . style . width = `${ animation . width } px` ;
206
- image . setAttribute ( `src` , spec . url ) ;
207
- } else {
208
- program . runtimeError ( command . lino , `Unknown animation type '${ spec . type } '` ) ;
209
- return 0 ;
181
+ if ( spec . start . width > 100 ) {
182
+ throw new Error ( `Start width too great for item ${ targetRecord . index } ` ) ;
183
+ }
184
+ if ( spec . finish . width > 100 ) {
185
+ throw new Error ( `Finish width too great for item ${ targetRecord . index } ` ) ;
186
+ }
187
+ if ( animation . widthS - animation . leftS < width ) {
188
+ throw new Error ( `Insufficient start width for item ${ targetRecord . index } ` ) ;
210
189
}
211
- case `opacity` :
212
- animation = targetRecord . animation [ targetRecord . index ] ;
190
+ if ( heightS - animation . topS < height ) {
191
+ throw new Error ( `Insufficient start height for item ${ targetRecord . index } ` ) ;
192
+ }
193
+ if ( animation . widthF - animation . leftF < width ) {
194
+ throw new Error ( `Insufficient finish width for item ${ targetRecord . index } ` ) ;
195
+ }
196
+ if ( heightF - animation . topF < height ) {
197
+ throw new Error ( `Insufficient finish height for item ${ targetRecord . index } ` ) ;
198
+ }
199
+ animation . left = animation . leftS ;
200
+ animation . top = animation . topS ;
201
+ animation . width = animation . widthS ;
213
202
let image = animation . image ;
214
- image . style . opacity = command . value ;
215
- break ;
203
+ image . style . left = `-${ animation . left } px` ;
204
+ image . style . top = `-${ animation . top } px` ;
205
+ image . style . width = `${ animation . width } px` ;
206
+ image . setAttribute ( `src` , spec . url ) ;
207
+ } else {
208
+ program . runtimeError ( command . lino , `Unknown animation type '${ spec . type } '` ) ;
209
+ return 0 ;
210
+ }
211
+ break ;
212
+ case `opacity` :
213
+ animation = targetRecord . animation [ targetRecord . index ] ;
214
+ let image = animation . image ;
215
+ image . style . opacity = command . value ;
216
+ break ;
216
217
}
217
218
return command . pc + 1 ;
218
219
}
@@ -297,20 +298,20 @@ const EasyCoder_VFX = {
297
298
298
299
getHandler : ( name ) => {
299
300
switch ( name ) {
300
- case `animation` :
301
- return EasyCoder_VFX . ANIMATION ;
302
- case `create` :
303
- return EasyCoder_VFX . Create ;
304
- case `on` :
305
- return EasyCoder_VFX . On ;
306
- case `set` :
307
- return EasyCoder_VFX . Set ;
308
- case `start` :
309
- return EasyCoder_VFX . Start ;
310
- case `step` :
311
- return EasyCoder_VFX . Step ;
312
- default :
313
- return null ;
301
+ case `animation` :
302
+ return EasyCoder_VFX . ANIMATION ;
303
+ case `create` :
304
+ return EasyCoder_VFX . Create ;
305
+ case `on` :
306
+ return EasyCoder_VFX . On ;
307
+ case `set` :
308
+ return EasyCoder_VFX . Set ;
309
+ case `start` :
310
+ return EasyCoder_VFX . Start ;
311
+ case `step` :
312
+ return EasyCoder_VFX . Step ;
313
+ default :
314
+ return null ;
314
315
}
315
316
} ,
316
317
0 commit comments