2021-08-04 20:58:17 +08:00

31 lines
850 B
TypeScript

import {IPropertyIdentValueDescriptor, PropertyDescriptorParsingType} from '../IPropertyDescriptor';
import {Context} from '../../core/context';
export enum POSITION {
STATIC = 0,
RELATIVE = 1,
ABSOLUTE = 2,
FIXED = 3,
STICKY = 4
}
export const position: IPropertyIdentValueDescriptor<POSITION> = {
name: 'position',
initialValue: 'static',
prefix: false,
type: PropertyDescriptorParsingType.IDENT_VALUE,
parse: (_context: Context, position: string) => {
switch (position) {
case 'relative':
return POSITION.RELATIVE;
case 'absolute':
return POSITION.ABSOLUTE;
case 'fixed':
return POSITION.FIXED;
case 'sticky':
return POSITION.STICKY;
}
return POSITION.STATIC;
}
};