MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / parsePosition

Function parsePosition

packages/core/ui/styling/background.ios.ts:466–493  ·  view source on GitHub ↗
(pos: string)

Source from the content-addressed store, hash-verified

464}
465
466function parsePosition(pos: string): { x: CSSValue; y: CSSValue } {
467 const values = cssParse(pos);
468 if (values.length === 2) {
469 // @ts-ignore
470 return { x: values[0], y: values[1] };
471 }
472
473 if (values.length === 1) {
474 const center = { type: 'ident', string: 'center' };
475
476 if (values[0].type === 'ident') {
477 const val = values[0].string.toLocaleLowerCase();
478
479 // If you only one keyword is specified, the other value is "center"
480 if (val === 'left' || val === 'right') {
481 return { x: values[0], y: center };
482 } else if (val === 'top' || val === 'bottom') {
483 return { x: center, y: values[0] };
484 } else if (val === 'center') {
485 return { x: center, y: center };
486 }
487 } else if (values[0].type === 'number') {
488 return { x: values[0], y: center };
489 }
490 }
491
492 return null;
493}
494
495function getDrawParams(this: void, image: UIImage, background: BackgroundDefinition, width: number, height: number): BackgroundDrawParams {
496 if (!image) {

Callers 1

getDrawParamsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected