Skip to content

Commit

Permalink
perf(module: picker): perf delete default data in component. (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guoyuanqiang authored and fisherspy committed Jan 31, 2019
1 parent 8759db0 commit ec748c3
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 3,720 deletions.
2 changes: 1 addition & 1 deletion components/picker-view/picker-view.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div #picker class="am-picker" style="flex-direction: row; align-items: center;">
<div *ngFor="let item of data; let i = index" class="am-picker-col">
<div *ngFor="let item of dataForRender; let i = index" class="am-picker-col">
<div #indicator class="am-picker-col-indicator " [ngStyle]="indicatorStyle"></div>
<div id={{i}} class="am-picker-col-mask" style="background-size: 100% 102px;"></div>
<div class="am-picker-col-content">
Expand Down
14 changes: 14 additions & 0 deletions components/picker-view/picker-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ export class PickerViewComponent extends PickerComponent implements OnInit, Afte
this.init();
}

init() {
this.selectedTarget = [];
if (this.dataForRender.length === 0 && this.generateArrayData(this.options.data).length > 0) {
this.dataForRender.push(this.generateArrayData(this.options.data));
}
if (this.options.value.length > 0) {
this.getInitValueIndex(this.dataForRender);
} else {
for (let index = 0; index < this.dataForRender.length; index++) {
this.selectedTarget.push({ targetId: `${index}`, currentY: 0 });
}
}
}

writeValue(value: any[]): void {
if (value) {
this.options.value = value;
Expand Down
Loading

1 comment on commit ec748c3

@Guoyuanqiang
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #266

Please sign in to comment.