MCPcopy Create free account
hub / github.com/Fiddle-Digital/string-scroll / parseSingle

Method parseSingle

src/StringParse.ts:28–44  ·  view source on GitHub ↗
(v: string, element: any, wH: any, baseRem: number)

Source from the content-addressed store, hash-verified

26 return oV;
27 }
28 public parseSingle(v: string, element: any, wH: any, baseRem: number): number {
29 let isNegative = v.startsWith('-');
30 if (isNegative) {
31 v = v.slice(1);
32 }
33 let pV;
34 if (v === 'selfHeight') {
35 pV = element.offsetHeight;
36 } else if (v.endsWith('px')) {
37 pV = parseFloat(v);
38 } else if (v.endsWith('%')) {
39 pV = parseFloat(v) * wH / 100;
40 } else if (v.endsWith('rem')) {
41 pV = parseFloat(v) * baseRem;
42 }
43 return isNegative ? -pV : pV;
44 }
45 public parseCalc(c: string, element: any, wH: any, baseRem: number): number {
46 c = c.slice(5, -1);
47 let ps = c.split(/([-+])/).filter(Boolean);

Callers 2

parseOffsetMethod · 0.95
parseCalcMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected