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 * @deprecated since 9 37 */ 38 Free, 39 40 /** 41 * Non-scrollable. 42 * @since 7 43 */ 44 None, 45} 46 47/** 48 * @since 7 49 */ 50declare class Scroller { 51 /** 52 * constructor. 53 * @since 7 54 */ 55 constructor(); 56 57 /** 58 * Called when the setting slides to the specified position. 59 * @since 7 60 */ 61 scrollTo(value: { 62 xOffset: number | string; 63 yOffset: number | string; 64 animation?: { duration: number; curve: Curve }; 65 }); 66 67 /** 68 * Called when scrolling to the edge of the container. 69 * @since 7 70 */ 71 scrollEdge(value: Edge); 72 73 /** 74 * Called when page turning mode is set. 75 * @since 7 76 * @deprecated since 9 77 */ 78 scrollPage(value: { next: boolean; direction?: Axis }); 79 80 /** 81 * Called when page turning mode is set. 82 * @since 9 83 */ 84 scrollPage(value: { next: boolean }); 85 86 /** 87 * Called when viewing the scroll offset. 88 * @since 7 89 */ 90 currentOffset(); 91 92 /** 93 * Called when sliding to the specified index. 94 * @since 7 95 */ 96 scrollToIndex(value: number); 97 98 /** 99 * Called when the setting slides by offset. 100 * @since 9 101 */ 102 scrollBy(dx: Length, dy: Length); 103} 104 105/** 106 * Provides interfaces for scrollable containers. 107 * @since 7 108 */ 109interface ScrollInterface { 110 /** 111 * Called when a scrollable container is set. 112 * @since 7 113 */ 114 (scroller?: Scroller): ScrollAttribute; 115} 116 117/** 118 * Defines the scroll attribute functions. 119 * @since 7 120 */ 121declare class ScrollAttribute extends CommonMethod<ScrollAttribute> { 122 /** 123 * Called when the scroll method is slid. 124 * @since 7 125 */ 126 scrollable(value: ScrollDirection): ScrollAttribute; 127 128 /** 129 * Called when the setting slides to the specified position. 130 * @since 7 131 */ 132 onScroll(event: (xOffset: number, yOffset: number) => void): ScrollAttribute; 133 134 /** 135 * Called when scrolling to the edge of the container. 136 * @since 7 137 */ 138 onScrollEdge(event: (side: Edge) => void): ScrollAttribute; 139 140 /** 141 * Called when scrolling start. 142 * @since 9 143 */ 144 onScrollStart(event: () => void): ScrollAttribute; 145 146 /** 147 * Called when scrolling has stopped. 148 * @since 7 149 * @deprecated since 9 150 * @useinstead scroll/Scroll#onScrollStop 151 */ 152 onScrollEnd(event: () => void): ScrollAttribute; 153 154 /** 155 * Called when scrolling has stopped. 156 * @since 9 157 */ 158 onScrollStop(event: () => void): ScrollAttribute; 159 160 /** 161 * Called when the status of the scroll bar is set. 162 * @since 7 163 */ 164 scrollBar(barState: BarState): ScrollAttribute; 165 166 /** 167 * Called when the color of the scroll bar is set. 168 * @since 7 169 */ 170 scrollBarColor(color: Color | number | string): ScrollAttribute; 171 172 /** 173 * Called when the width of the scroll bar is set. 174 * @since 7 175 */ 176 scrollBarWidth(value: number | string): ScrollAttribute; 177 178 /** 179 * Called when the sliding effect is set. 180 * @since 7 181 */ 182 edgeEffect(edgeEffect: EdgeEffect): ScrollAttribute; 183 184 /** 185 * Called when scrolling begin each frame. 186 * @since 9 187 */ 188 onScrollFrameBegin(event: (offset: number, state: ScrollState) => { offsetRemain: number }): ScrollAttribute; 189} 190 191/** 192 * Defines Scroll Component. 193 * @since 7 194 */ 195declare const Scroll: ScrollInterface; 196 197/** 198 * Defines Scroll Component instance. 199 * @since 7 200 */ 201declare const ScrollInstance: ScrollAttribute; 202