• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16/**
17 * Content scroll direction.
18 * @since 7
19 */
20declare enum ScrollDirection {
21  /**
22   * Vertical scrolling is supported.
23   * @since 7
24   */
25  Vertical,
26
27  /**
28   * Horizontal scrolling is supported.
29   * @since 7
30   */
31  Horizontal,
32
33  /**
34   * Free scrolling is supported.
35   * @since 7
36   */
37  Free,
38
39  /**
40   * Non-scrollable.
41   * @since 7
42   */
43  None,
44}
45
46/**
47 * @since 7
48 */
49declare class Scroller {
50  /**
51   * constructor.
52   * @since 7
53   */
54  constructor();
55
56  /**
57   * Called when the setting slides to the specified position.
58   * @since 7
59   */
60  scrollTo(value: {
61    xOffset: number | string;
62    yOffset: number | string;
63    animation?: { duration: number; curve: Curve };
64  });
65
66  /**
67   * Called when scrolling to the edge of the container.
68   * @since 7
69   */
70  scrollEdge(value: Edge);
71
72  /**
73   * Called when page turning mode is set.
74   * @since 7
75   */
76  scrollPage(value: { next: boolean; direction?: Axis });
77
78  /**
79   * Called when viewing the scroll offset.
80   * @since 7
81   */
82  currentOffset();
83
84  /**
85   * Called when sliding to the specified index.
86   * @since 7
87   */
88  scrollToIndex(value: number);
89}
90
91/**
92 * Provides interfaces for scrollable containers.
93 * @since 7
94 */
95interface ScrollInterface {
96  /**
97   * Called when a scrollable container is set.
98   * @since 7
99   */
100  (scroller?: Scroller): ScrollAttribute;
101}
102
103/**
104 * Defines the scroll attibute functions.
105 * @since 7
106 */
107declare class ScrollAttribute extends CommonMethod<ScrollAttribute> {
108  /**
109   * Called when the scroll method is slid.
110   * @since 7
111   */
112  scrollable(value: ScrollDirection): ScrollAttribute;
113
114  /**
115   * Called when the setting slides to the specified position.
116   * @since 7
117   */
118  onScroll(event: (xOffset: number, yOffset: number) => void): ScrollAttribute;
119
120  /**
121   * Called when scrolling to the edge of the container.
122   * @since 7
123   */
124  onScrollEdge(event: (side: Edge) => void): ScrollAttribute;
125
126  /**
127   * Called when scrolling has stopped.
128   * @since 7
129   */
130  onScrollEnd(event: () => void): ScrollAttribute;
131
132  /**
133   * Called when the status of the scroll bar is set.
134   * @since 7
135   */
136  scrollBar(barState: BarState): ScrollAttribute;
137
138  /**
139   * Called when the color of the scroll bar is set.
140   * @since 7
141   */
142  scrollBarColor(color: Color | number | string): ScrollAttribute;
143
144  /**
145   * Called when the width of the scroll bar is set.
146   * @since 7
147   */
148  scrollBarWidth(value: number | string): ScrollAttribute;
149
150  /**
151   * Called when the sliding effect is set.
152   * @since 7
153   */
154  edgeEffect(edgeEffect: EdgeEffect): ScrollAttribute;
155}
156
157declare const Scroll: ScrollInterface;
158declare const ScrollInstance: ScrollAttribute;
159