• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15@Entry
16@Component
17struct PinchTest {
18  scroller: Scroller = new Scroller()
19  private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
20
21  build() {
22    Column() {
23      Text('VerticalScroll')
24        .fontSize(25)
25        .fontWeight(FontWeight.Bold)
26      Scroll(this.scroller) {
27        Column() {
28          ForEach(this.arr, (item: number) => {
29            Text(item.toString())
30              .width('90%')
31              .height('40%')
32              .backgroundColor(0xDCDCDC)
33              .fontSize(80)
34              .textAlign(TextAlign.Center)
35              .margin({ top: 10 })
36          }, (item: string) => item)
37        }
38      }
39      .id('verticalScroll')
40      .width('100%')
41      .height('50%')
42      .scrollable(ScrollDirection.Vertical)
43      .scrollBar(BarState.On)
44      .scrollBarColor(Color.Gray)
45      .scrollBarWidth(30)
46
47
48      Text('HorizontalScroll')
49        .fontSize(25)
50        .fontWeight(FontWeight.Bold)
51      Stack({ alignContent: Alignment.Center }) {
52        Scroll(this.scroller) {
53          Row() {
54            ForEach(this.arr, (item: number) => {
55              Text(item.toString())
56                .width('20%')
57                .height('90%')
58                .backgroundColor(0xDCDCDC)
59                .fontSize(80)
60                .textAlign(TextAlign.Center)
61                .margin({ top: 10 })
62            }, (item: string) => item)
63          }
64        }
65        .id('horizontalScroll')
66        .width('100%')
67        .height('100%')
68        .scrollable(ScrollDirection.Horizontal)
69        .scrollBar(BarState.On)
70        .scrollBarColor(Color.Gray)
71        .scrollBarWidth(30)
72
73        Text('Offset Start')
74          .fontSize(10)
75          .fontWeight(FontWeight.Bold)
76          .width('20%')
77          .height('100%')
78          .position({left: 0})
79          .backgroundColor(Color.Gray)
80
81        Text('Offset End')
82          .fontSize(10)
83          .fontWeight(FontWeight.Bold)
84          .width('20%')
85          .height('100%')
86          .position({right: 0})
87          .backgroundColor(Color.Gray)
88      }
89      .width('80%')
90      .height('50%')
91    }
92    .width('100%')
93    .height('100%')
94    .justifyContent(FlexAlign.Center)
95  }
96}