UNPKG

nehan

Version:

Html layout engine for paged-media written in Typescript

57 lines 2.11 kB
import { CssText, CssCascade, Utils, } from "./public-api"; export class LogicalBorderRadius { constructor(values) { this.beforeStart = values.beforeStart; this.beforeEnd = values.beforeEnd; this.afterEnd = values.afterEnd; this.afterStart = values.afterStart; } clone() { return new LogicalBorderRadius({ beforeStart: this.beforeStart, beforeEnd: this.beforeEnd, afterEnd: this.afterEnd, afterStart: this.afterStart }); } static get none() { return new LogicalBorderRadius(LogicalBorderRadius.noneValue); } static get noneValue() { return { beforeStart: 0, beforeEnd: 0, afterEnd: 0, afterStart: 0 }; } static load(element) { let values = LogicalBorderRadius.corners.reduce((values, corner) => { let prop = `border-${corner}-radius`; let value = CssCascade.getValue(element, prop); values[Utils.String.chainToCamel(corner)] = value; return values; }, {}); return new LogicalBorderRadius(values); } static parseShorthand(css_text) { let hvs = CssText.getValue4D2(css_text.value); let h4 = hvs[0], v4 = hvs[1]; return [ { prop: "border-before-start-radius", value: [h4[0], v4[0]].join(" ") }, { prop: "border-before-end-radius", value: [h4[1], v4[1]].join(" ") }, { prop: "border-after-end-radius", value: [h4[2], v4[2]].join(" ") }, { prop: "border-after-start-radius", value: [h4[3], v4[3]].join(" ") } ]; } get items() { return [ { prop: "before-start", value: this.beforeStart }, { prop: "before-end", value: this.beforeEnd }, { prop: "after-end", value: this.afterEnd }, { prop: "after-start", value: this.afterStart } ]; } } LogicalBorderRadius.corners = ["before-start", "before-end", "after-end", "after-start"]; //# sourceMappingURL=logical-border-radius.js.map