เปิดใช้งานการปัดใน TabView

ฉันใช้ NativeScript Angular และมี TabView ที่ตั้งค่าไว้ที่ตำแหน่งด้านล่าง ฉันต้องการให้ผู้ใช้สามารถปัดระหว่างแท็บทั้งบน iOS และ Android แต่ใน เอกสาร TabView ระบุว่าการปัดถูกปิดใช้งานเมื่อตั้งค่าตำแหน่งไว้ที่ด้านล่าง

ฉันจะเปิดใช้งานการปัดบน TabView ได้อย่างไร


person Graham    schedule 03.08.2018    source แหล่งที่มา


คำตอบ (1)


หลังจากอ่านเกี่ยวกับ Gesture API แล้ว ฉันลงเอยด้วยการเพิ่มตัวฟังเหตุการณ์การปัดลงใน TabView:

HTML:

<TabView #tabview (swipe)="onSwipe($event)" androidTabsPosition="bottom">

    <page-router-outlet
        *tabItem="{title: 'Start', iconSource: getIconSource('play')}"
        name="startTab">
    </page-router-outlet>

    <page-router-outlet
        *tabItem="{title: 'Settings', iconSource: getIconSource('settings')}"
        name="settingsTab">
    </page-router-outlet>

</TabView>

พิมพ์สคริปต์:

@ViewChild("tabview") tabview!: ElementRef<TabView>;
...
  onSwipe(event: SwipeGestureEventData) {
    if (this.tabview.nativeElement.selectedIndex === 0 && event.direction === SwipeDirection.left){
      this.tabview.nativeElement.selectedIndex = 1;
    } else if(this.tabview.nativeElement.selectedIndex === 1 && event.direction === SwipeDirection.right){
      this.tabview.nativeElement.selectedIndex = 0;
    }
  }
...
person Graham    schedule 05.08.2018
comment
ฉันคิดว่านี่คงไม่มีภาพเคลื่อนไหว 'สไลด์' เมื่อคุณปัดมันใช่ไหม - person Muhammad bin Yusrat; 28.06.2019