Commit 9537ecf 1 parent fd7b1ac commit 9537ecf Copy full SHA for 9537ecf
File tree 5 files changed +20
-21
lines changed
5 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,7 @@ enum FramePointType {
10
10
BOTTOMRIGHT = 8 ,
11
11
}
12
12
13
- export const stringToPointType = ( string ?: string ) => {
14
- if ( ! string ) return undefined ;
15
- return FramePointType [ string . toUpperCase ( ) as keyof typeof FramePointType ] ;
16
- } ;
17
-
18
- export const FramePointTypeSide = {
13
+ const FramePointTypeSide = {
19
14
CENTERX : [
20
15
FramePointType . TOP ,
21
16
FramePointType . CENTER ,
@@ -49,3 +44,4 @@ export const FramePointTypeSide = {
49
44
} ;
50
45
51
46
export default FramePointType ;
47
+ export { FramePointTypeSide } ;
Original file line number Diff line number Diff line change 1
1
import ScriptRegion from './ScriptRegion' ;
2
2
import XMLNode from '../../XMLNode' ;
3
+ import { stringToFramePointType } from '../../utils' ;
3
4
import {
4
5
EPSILON1 ,
5
6
EPSILON2 ,
@@ -18,10 +19,7 @@ import {
18
19
} from '../../../utils' ;
19
20
20
21
import FramePoint from './FramePoint' ;
21
- import FramePointType , {
22
- FramePointTypeSide ,
23
- stringToPointType ,
24
- } from './FramePointType' ;
22
+ import FramePointType , { FramePointTypeSide } from './FramePointType' ;
25
23
26
24
class FrameNode extends LinkedListNode {
27
25
frame : LayoutFrame ;
@@ -397,16 +395,16 @@ class LayoutFrame {
397
395
const relativePointValue = child . attributes . get ( 'relativePoint' ) ;
398
396
const relativeValue = child . attributes . get ( 'relativeTo' ) ;
399
397
400
- const pointType = stringToPointType ( pointValue ) ;
398
+ const pointType = stringToFramePointType ( pointValue ) ;
401
399
let relativePointType = pointType ;
402
- if ( ! pointType ) {
400
+ if ( pointType === undefined ) {
403
401
// TODO: Error handling
404
402
continue ;
405
403
}
406
404
407
405
if ( relativePointValue ) {
408
- relativePointType = stringToPointType ( relativePointValue ) ;
409
- if ( ! relativePointType ) {
406
+ relativePointType = stringToFramePointType ( relativePointValue ) ;
407
+ if ( relativePointType === undefined ) {
410
408
// TODO: Error handling
411
409
continue ;
412
410
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import {
19
19
import { Rect } from '../../../math' ;
20
20
import {
21
21
stringToDrawLayerType ,
22
- stringToStrataType ,
22
+ stringToFrameStrataType ,
23
23
} from '../../utils' ;
24
24
25
25
import FrameFlag from './FrameFlag' ;
@@ -308,8 +308,8 @@ class Frame extends ScriptRegion {
308
308
}
309
309
310
310
if ( frameStrata ) {
311
- const strataType = stringToStrataType ( frameStrata ) ;
312
- if ( strataType ) {
311
+ const strataType = stringToFrameStrataType ( frameStrata ) ;
312
+ if ( strataType !== undefined ) {
313
313
this . setFrameStrataType ( strataType ) ;
314
314
} else {
315
315
// TODO: Error handling
@@ -371,8 +371,7 @@ class Frame extends ScriptRegion {
371
371
372
372
const level = layer . attributes . get ( 'level' ) ;
373
373
374
- // TODO: Case sensitivity
375
- const drawLayerType = stringToDrawLayerType ( level ) || DrawLayerType . ARTWORK ;
374
+ const drawLayerType = stringToDrawLayerType ( level ) ?? DrawLayerType . ARTWORK ;
376
375
377
376
for ( const layerChild of layer . children ) {
378
377
const iname = layerChild . name . toLowerCase ( ) ;
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ class Texture extends Region {
240
240
241
241
if ( alphaMode ) {
242
242
const blendMode = stringToBlendMode ( alphaMode ) ;
243
- if ( blendMode ) {
243
+ if ( blendMode !== undefined ) {
244
244
this . setBlendMode ( blendMode ) ;
245
245
}
246
246
}
Original file line number Diff line number Diff line change 1
1
import { BlendMode } from '../gfx/types' ;
2
2
3
3
import DrawLayerType from './DrawLayerType' ;
4
+ import FramePointType from './components/abstract/FramePointType' ;
4
5
import FrameStrataType from './components/abstract/FrameStrataType' ;
5
6
6
7
export const stringToBlendMode = ( string ?: string ) => {
@@ -13,7 +14,12 @@ export const stringToDrawLayerType = (string?: string) => {
13
14
return DrawLayerType [ string ?. toUpperCase ( ) as keyof typeof DrawLayerType ] ;
14
15
} ;
15
16
16
- export const stringToStrataType = ( string ?: string ) => {
17
+ export const stringToFramePointType = ( string ?: string ) => {
18
+ if ( ! string ) return undefined ;
19
+ return FramePointType [ string . toUpperCase ( ) as keyof typeof FramePointType ] ;
20
+ } ;
21
+
22
+ export const stringToFrameStrataType = ( string ?: string ) => {
17
23
if ( ! string ) return undefined ;
18
24
return FrameStrataType [ string ?. toUpperCase ( ) as keyof typeof FrameStrataType ] ;
19
25
} ;
You can’t perform that action at this time.
0 commit comments