diff --git a/src/components.d.ts b/src/components.d.ts index 7497e1c..6fc3872 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -1,8 +1,8 @@ +/* tslint:disable */ /** * This is an autogenerated file created by the Stencil compiler. * It contains typing information for all components that exist in this project. */ -/* tslint:disable */ import '@stencil/core'; @@ -13,20 +13,20 @@ export namespace Components { interface SplitMe { d: 'horizontal' | 'vertical'; fixed: boolean; - maxSizes: string; - minSizes: string; + maxSizes: string | number[]; + minSizes: string | number[]; n: number; - sizes: string; + sizes: string | number[]; throttle: number; } interface SplitMeAttributes extends StencilHTMLAttributes { d?: 'horizontal' | 'vertical'; fixed?: boolean; - maxSizes?: string; - minSizes?: string; + maxSizes?: string | number[]; + minSizes?: string | number[]; n?: number; onSlotResized?: (event: CustomEvent) => void; - sizes?: string; + sizes?: string | number[]; throttle?: number; } } diff --git a/src/components/split-me/split-me.tsx b/src/components/split-me/split-me.tsx index 4ab9f06..a822fa8 100644 --- a/src/components/split-me/split-me.tsx +++ b/src/components/split-me/split-me.tsx @@ -29,11 +29,11 @@ export class SplitMe { @Prop() fixed: boolean = false; @Prop() - sizes: string = ''; + sizes: string | number[] = ''; @Prop() - minSizes: string = ''; + minSizes: string | number[] = ''; @Prop() - maxSizes: string = ''; + maxSizes: string | number[] = ''; @Prop() throttle: number = 0; @@ -192,10 +192,19 @@ export class SplitMe { return maxSizes; } - parseSizes(sizesStr: string): number[] { + parseSizes(sizesStr: string | number[]): number[] { if (!sizesStr) { return []; } + + if (Array.isArray(sizesStr)) { + if (sizesStr.length == this.n) { + return sizesStr; + } else { + return []; + } + } + let sizesStrArr: string[] = sizesStr.split(','); if (sizesStrArr.length !== this.n) { return []; diff --git a/src/index.html b/src/index.html index f0b341c..d9bcff5 100644 --- a/src/index.html +++ b/src/index.html @@ -62,8 +62,11 @@ }); let i = 0; let n = 0; - let interval = setTimeout(()=>{ - splitter.throttle = 0; + setTimeout(()=>{ + splitter.sizes = "0.75, 0.25"; + }, 2000); + setTimeout(()=>{ + splitter.sizes = [0.25, 0.75]; }, 4000);