@@ -204,18 +204,23 @@ function parsePosition(pos: string): { x: CSSValue, y: CSSValue } {
204204 return { x : values [ 0 ] , y : values [ 1 ] } ;
205205 }
206206
207- if ( values . length === 1 && values [ 0 ] . type === "ident" ) {
208- const val = values [ 0 ] . string . toLocaleLowerCase ( ) ;
209- const center = { type : "ident" , string : "center" } ;
210-
211- // If you only one keyword is specified, the other value is "center"
212- if ( val === "left" || val === "right" ) {
213- return { x : values [ 0 ] , y : center } ;
214- } else if ( val === "top" || val === "bottom" ) {
215- return { x : center , y : values [ 0 ] } ;
216- } else if ( val === "center" ) {
217- return { x : center , y : center } ;
218- }
207+ if ( values . length === 1 ) {
208+ const center = { type : "ident" , string : "center" } ;
209+
210+ if ( values [ 0 ] . type === "ident" ) {
211+ const val = values [ 0 ] . string . toLocaleLowerCase ( ) ;
212+
213+ // If you only one keyword is specified, the other value is "center"
214+ if ( val === "left" || val === "right" ) {
215+ return { x : values [ 0 ] , y : center } ;
216+ } else if ( val === "top" || val === "bottom" ) {
217+ return { x : center , y : values [ 0 ] } ;
218+ } else if ( val === "center" ) {
219+ return { x : center , y : center } ;
220+ }
221+ } else if ( values [ 0 ] . type === "number" ) {
222+ return { x : values [ 0 ] , y : center } ;
223+ }
219224 }
220225
221226 return null ;
@@ -322,6 +327,18 @@ function getDrawParams(this: void, image: UIImage, background: BackgroundDefinit
322327 } else if ( v . y . string . toLowerCase ( ) === "bottom" ) {
323328 res . posY = spaceY ;
324329 }
330+ } else if ( v . x . type === "number" && v . y . type === "ident" ) {
331+ if ( v . x . unit === "%" ) {
332+ res . posX = spaceX * v . x . value / 100 ;
333+ } else if ( v . x . type === "number" || v . x . unit === "px" || v . x . unit === "" ) {
334+ res . posX = v . x . value ;
335+ }
336+
337+ if ( v . y . string . toLowerCase ( ) === "center" ) {
338+ res . posY = spaceY / 2 ;
339+ } else if ( v . y . string . toLowerCase ( ) === "bottom" ) {
340+ res . posY = spaceY ;
341+ }
325342 }
326343 }
327344 }
0 commit comments