1/* 2 * Copyright (c) 2021-2023 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 * 19 * @enum { number } 20 * @syscap SystemCapability.ArkUI.ArkUI.Full 21 * @since 7 22 */ 23/** 24 * Content scroll direction. 25 * 26 * @enum { number } 27 * @syscap SystemCapability.ArkUI.ArkUI.Full 28 * @crossplatform 29 * @since 10 30 */ 31declare enum ScrollDirection { 32 /** 33 * Vertical scrolling is supported. 34 * 35 * @syscap SystemCapability.ArkUI.ArkUI.Full 36 * @since 7 37 */ 38 /** 39 * Vertical scrolling is supported. 40 * 41 * @syscap SystemCapability.ArkUI.ArkUI.Full 42 * @crossplatform 43 * @since 10 44 */ 45 Vertical, 46 47 /** 48 * Horizontal scrolling is supported. 49 * 50 * @syscap SystemCapability.ArkUI.ArkUI.Full 51 * @since 7 52 */ 53 /** 54 * Horizontal scrolling is supported. 55 * 56 * @syscap SystemCapability.ArkUI.ArkUI.Full 57 * @crossplatform 58 * @since 10 59 */ 60 Horizontal, 61 62 /** 63 * Free scrolling is supported. 64 * 65 * @syscap SystemCapability.ArkUI.ArkUI.Full 66 * @since 7 67 * @deprecated since 9 68 */ 69 Free, 70 71 /** 72 * Non-scrollable. 73 * 74 * @syscap SystemCapability.ArkUI.ArkUI.Full 75 * @since 7 76 */ 77 /** 78 * Non-scrollable. 79 * 80 * @syscap SystemCapability.ArkUI.ArkUI.Full 81 * @crossplatform 82 * @since 10 83 */ 84 None, 85} 86 87/** 88 * ScrollAlign. 89 * 90 * @enum { number } ScrollAlign 91 * @syscap SystemCapability.ArkUI.ArkUI.Full 92 * @crossplatform 93 * @since 10 94 */ 95declare enum ScrollAlign { 96 /** 97 * Start position alignment. 98 * 99 * @syscap SystemCapability.ArkUI.ArkUI.Full 100 * @crossplatform 101 * @since 10 102 */ 103 START, 104 105 /** 106 * Center alignment. 107 * 108 * @syscap SystemCapability.ArkUI.ArkUI.Full 109 * @crossplatform 110 * @since 10 111 */ 112 CENTER, 113 114 /** 115 * End position alignment. 116 * 117 * @syscap SystemCapability.ArkUI.ArkUI.Full 118 * @crossplatform 119 * @since 10 120 */ 121 END, 122 123 /** 124 * Scroll the minimum distance to fully display the specified item. 125 * 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @crossplatform 128 * @since 10 129 */ 130 AUTO, 131} 132 133/** 134 * @since 7 135 */ 136/** 137 * @crossplatform 138 * @since 10 139 */ 140declare class Scroller { 141 /** 142 * constructor. 143 * 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @since 7 146 */ 147 /** 148 * constructor. 149 * 150 * @syscap SystemCapability.ArkUI.ArkUI.Full 151 * @crossplatform 152 * @since 10 153 */ 154 constructor(); 155 156 /** 157 * Called when the setting slides to the specified position. 158 * 159 * @param { object } value 160 * @syscap SystemCapability.ArkUI.ArkUI.Full 161 * @since 7 162 */ 163 /** 164 * Called when the setting slides to the specified position. 165 * 166 * @param { object } value 167 * @syscap SystemCapability.ArkUI.ArkUI.Full 168 * @crossplatform 169 * @since 10 170 */ 171 scrollTo(value: { 172 /** 173 * The X-axis offset. 174 * 175 * @type { number | string } 176 * @syscap SystemCapability.ArkUI.ArkUI.Full 177 * @crossplatform 178 * @since 10 179 */ 180 xOffset: number | string; 181 182 /** 183 * The Y-axis offset. 184 * 185 * @type { number | string } 186 * @syscap SystemCapability.ArkUI.ArkUI.Full 187 * @crossplatform 188 * @since 10 189 */ 190 yOffset: number | string; 191 192 /** 193 * Descriptive animation. 194 * 195 * @type { ?object } The object type provides custom animation parameters 196 * and the boolean type enables default spring animation. 197 * @syscap SystemCapability.ArkUI.ArkUI.Full 198 * @crossplatform 199 * @since 10 200 */ 201 animation?: { duration?: number; curve?: Curve | ICurve } | boolean; 202 }); 203 204 /** 205 * Called when scrolling to the edge of the container. 206 * 207 * @param { Edge } value 208 * @syscap SystemCapability.ArkUI.ArkUI.Full 209 * @since 7 210 */ 211 /** 212 * Called when scrolling to the edge of the container. 213 * 214 * @param { Edge } value 215 * @syscap SystemCapability.ArkUI.ArkUI.Full 216 * @crossplatform 217 * @since 10 218 */ 219 scrollEdge(value: Edge); 220 221 /** 222 * Called when page turning mode is set. 223 * 224 * @param { object } value 225 * @syscap SystemCapability.ArkUI.ArkUI.Full 226 * @since 9 227 */ 228 /** 229 * Called when page turning mode is set. 230 * 231 * @param { object } value 232 * @syscap SystemCapability.ArkUI.ArkUI.Full 233 * @crossplatform 234 * @since 10 235 */ 236 scrollPage(value: { next: boolean }); 237 238 /** 239 * Called when page turning mode is set. 240 * 241 * @param { object } value 242 * @syscap SystemCapability.ArkUI.ArkUI.Full 243 * @since 7 244 * @deprecated since 9 245 */ 246 scrollPage(value: { next: boolean; direction?: Axis }); 247 248 /** 249 * Called when viewing the scroll offset. 250 * 251 * @syscap SystemCapability.ArkUI.ArkUI.Full 252 * @since 7 253 */ 254 /** 255 * Called when viewing the scroll offset. 256 * 257 * @syscap SystemCapability.ArkUI.ArkUI.Full 258 * @crossplatform 259 * @since 10 260 */ 261 currentOffset(); 262 263 /** 264 * Called when sliding to the specified index. 265 * 266 * @param { number } value 267 * @param { boolean } smooth 268 * @param { ScrollAlign } align 269 * @syscap SystemCapability.ArkUI.ArkUI.Full 270 * @since 7 271 */ 272 /** 273 * Called when sliding to the specified index. 274 * 275 * @param { number } value - Index to jump to. 276 * @param { boolean } smooth - If true, scroll to index item with animation. If false, scroll to index item without animation. 277 * @param { ScrollAlign } align - Sets the alignment mode of a specified index. 278 * @syscap SystemCapability.ArkUI.ArkUI.Full 279 * @crossplatform 280 * @since 10 281 */ 282 scrollToIndex(value: number, smooth?: boolean, align?: ScrollAlign); 283 284 /** 285 * Called when the setting slides by offset. 286 * 287 * @param { Length } dx 288 * @param { Length } dy 289 * @syscap SystemCapability.ArkUI.ArkUI.Full 290 * @since 9 291 */ 292 /** 293 * Called when the setting slides by offset. 294 * 295 * @param { Length } dx 296 * @param { Length } dy 297 * @syscap SystemCapability.ArkUI.ArkUI.Full 298 * @crossplatform 299 * @since 10 300 */ 301 scrollBy(dx: Length, dy: Length); 302 303 /** 304 * Indicates whether the component scrolls to the end position. 305 * 306 * @returns { boolean } Returns whether the component scrolls to the end position. 307 * @syscap SystemCapability.ArkUI.ArkUI.Full 308 * @crossplatform 309 * @since 10 310 */ 311 isAtEnd(): boolean; 312} 313 314/* 315 * Define scroll snap options 316 * @syscap SystemCapability.ArkUI.ArkUI.Full 317 * @since 10 318 */ 319declare interface ScrollSnapOptions { 320 /** 321 * Set scroll snap alignment. 322 * 323 * @type { ScrollSnapAlign } 324 * @syscap SystemCapability.ArkUI.ArkUI.Full 325 * @since 10 326 */ 327 snapAlign: ScrollSnapAlign; 328 329 /** 330 * Set snap positions. When the type of snapPositions is Dimension, Scroll content is paginated by an integer 331 * multiple of snapPositions. When the type of snapPositions is Array<number>, Scroll content is paginated based 332 * on the array of snapPositions. 333 * 334 * @type { ?(Dimension | Array<Dimension>) } 335 * @default 100% 336 * @syscap SystemCapability.ArkUI.ArkUI.Full 337 * @since 10 338 */ 339 snapPagination?: Dimension | Array<Dimension>; 340 341 /** 342 * Set whether the beginning of the Scroll content counts an a snap. 343 * 344 * @type { ?boolean } 345 * @default true 346 * @syscap SystemCapability.ArkUI.ArkUI.Full 347 * @since 10 348 */ 349 enableSnapToStart?: boolean; 350 351 /** 352 * Set whether the end of the Scroll content counts an a snap. 353 * 354 * @type { ?boolean } 355 * @default true 356 * @syscap SystemCapability.ArkUI.ArkUI.Full 357 * @since 10 358 */ 359 enableSnapToEnd?: boolean; 360} 361 362/** 363 * Provides interfaces for scrollable containers. 364 * 365 * @interface ScrollInterface 366 * @syscap SystemCapability.ArkUI.ArkUI.Full 367 * @since 7 368 */ 369/** 370 * Provides interfaces for scrollable containers. 371 * 372 * @interface ScrollInterface 373 * @syscap SystemCapability.ArkUI.ArkUI.Full 374 * @crossplatform 375 * @since 10 376 */ 377interface ScrollInterface { 378 /** 379 * Called when a scrollable container is set. 380 * 381 * @param { Scroller } scroller 382 * @returns { ScrollAttribute } 383 * @syscap SystemCapability.ArkUI.ArkUI.Full 384 * @since 7 385 */ 386 /** 387 * Called when a scrollable container is set. 388 * 389 * @param { Scroller } scroller 390 * @returns { ScrollAttribute } 391 * @syscap SystemCapability.ArkUI.ArkUI.Full 392 * @crossplatform 393 * @since 10 394 */ 395 (scroller?: Scroller): ScrollAttribute; 396} 397 398/** 399 * Defines the scroll attribute functions. 400 * 401 * @extends CommonMethod 402 * @syscap SystemCapability.ArkUI.ArkUI.Full 403 * @since 7 404 */ 405/** 406 * Defines the scroll attribute functions. 407 * 408 * @extends CommonMethod 409 * @syscap SystemCapability.ArkUI.ArkUI.Full 410 * @crossplatform 411 * @since 10 412 */ 413declare class ScrollAttribute extends CommonMethod<ScrollAttribute> { 414 /** 415 * Called when the scroll method is slid. 416 * 417 * @param { ScrollDirection } value 418 * @returns { ScrollAttribute } 419 * @syscap SystemCapability.ArkUI.ArkUI.Full 420 * @since 7 421 */ 422 /** 423 * Called when the scroll method is slid. 424 * 425 * @param { ScrollDirection } value 426 * @returns { ScrollAttribute } 427 * @syscap SystemCapability.ArkUI.ArkUI.Full 428 * @crossplatform 429 * @since 10 430 */ 431 scrollable(value: ScrollDirection): ScrollAttribute; 432 433 /** 434 * Called when the setting slides to the specified position. 435 * 436 * @param { function } event 437 * @returns { ScrollAttribute } 438 * @syscap SystemCapability.ArkUI.ArkUI.Full 439 * @since 7 440 */ 441 /** 442 * Called when the setting slides to the specified position. 443 * 444 * @param { function } event 445 * @returns { ScrollAttribute } 446 * @syscap SystemCapability.ArkUI.ArkUI.Full 447 * @crossplatform 448 * @since 10 449 */ 450 onScroll(event: (xOffset: number, yOffset: number) => void): ScrollAttribute; 451 452 /** 453 * Called when scrolling to the edge of the container. 454 * 455 * @param { function } event 456 * @returns { ScrollAttribute } 457 * @syscap SystemCapability.ArkUI.ArkUI.Full 458 * @since 7 459 */ 460 /** 461 * Called when scrolling to the edge of the container. 462 * 463 * @param { function } event 464 * @returns { ScrollAttribute } 465 * @syscap SystemCapability.ArkUI.ArkUI.Full 466 * @crossplatform 467 * @since 10 468 */ 469 onScrollEdge(event: (side: Edge) => void): ScrollAttribute; 470 471 /** 472 * Called when scrolling start. 473 * 474 * @param { function } event 475 * @returns { ScrollAttribute } 476 * @syscap SystemCapability.ArkUI.ArkUI.Full 477 * @since 9 478 */ 479 /** 480 * Called when scrolling start. 481 * 482 * @param { function } event 483 * @returns { ScrollAttribute } 484 * @syscap SystemCapability.ArkUI.ArkUI.Full 485 * @crossplatform 486 * @since 10 487 */ 488 onScrollStart(event: () => void): ScrollAttribute; 489 490 /** 491 * Called when scrolling has stopped. 492 * 493 * @param { function } event 494 * @returns { ScrollAttribute } 495 * @syscap SystemCapability.ArkUI.ArkUI.Full 496 * @since 7 497 * @deprecated since 9 498 * @useinstead scroll/Scroll#onScrollStop 499 */ 500 onScrollEnd(event: () => void): ScrollAttribute; 501 502 /** 503 * Called when scrolling has stopped. 504 * 505 * @param { function } event 506 * @returns { ScrollAttribute } 507 * @syscap SystemCapability.ArkUI.ArkUI.Full 508 * @since 9 509 */ 510 /** 511 * Called when scrolling has stopped. 512 * 513 * @param { function } event 514 * @returns { ScrollAttribute } 515 * @syscap SystemCapability.ArkUI.ArkUI.Full 516 * @crossplatform 517 * @since 10 518 */ 519 onScrollStop(event: () => void): ScrollAttribute; 520 521 /** 522 * Called when the status of the scroll bar is set. 523 * 524 * @param { BarState } barState 525 * @returns { ScrollAttribute } 526 * @syscap SystemCapability.ArkUI.ArkUI.Full 527 * @since 7 528 */ 529 /** 530 * Called when the status of the scroll bar is set. 531 * 532 * @param { BarState } barState 533 * @returns { ScrollAttribute } 534 * @syscap SystemCapability.ArkUI.ArkUI.Full 535 * @crossplatform 536 * @since 10 537 */ 538 scrollBar(barState: BarState): ScrollAttribute; 539 540 /** 541 * Called when the color of the scroll bar is set. 542 * 543 * @param { Color | number | string } color 544 * @returns { ScrollAttribute } 545 * @syscap SystemCapability.ArkUI.ArkUI.Full 546 * @since 7 547 */ 548 /** 549 * Called when the color of the scroll bar is set. 550 * 551 * @param { Color | number | string } color 552 * @returns { ScrollAttribute } 553 * @syscap SystemCapability.ArkUI.ArkUI.Full 554 * @crossplatform 555 * @since 10 556 */ 557 scrollBarColor(color: Color | number | string): ScrollAttribute; 558 559 /** 560 * Called when the width of the scroll bar is set. 561 * 562 * @param { number | string } value 563 * @returns { ScrollAttribute } 564 * @syscap SystemCapability.ArkUI.ArkUI.Full 565 * @since 7 566 */ 567 /** 568 * Called when the width of the scroll bar is set. 569 * 570 * @param { number | string } value 571 * @returns { ScrollAttribute } 572 * @syscap SystemCapability.ArkUI.ArkUI.Full 573 * @crossplatform 574 * @since 10 575 */ 576 scrollBarWidth(value: number | string): ScrollAttribute; 577 578 /** 579 * Called when the sliding effect is set. 580 * 581 * @param { EdgeEffect } edgeEffect 582 * @returns { ScrollAttribute } 583 * @syscap SystemCapability.ArkUI.ArkUI.Full 584 * @since 7 585 */ 586 /** 587 * Called when the sliding effect is set. 588 * 589 * @param { EdgeEffect } edgeEffect 590 * @returns { ScrollAttribute } 591 * @syscap SystemCapability.ArkUI.ArkUI.Full 592 * @crossplatform 593 * @since 10 594 */ 595 edgeEffect(edgeEffect: EdgeEffect): ScrollAttribute; 596 597 /** 598 * Called when scrolling begin each frame. 599 * 600 * @param { function } event 601 * @returns { ScrollAttribute } 602 * @syscap SystemCapability.ArkUI.ArkUI.Full 603 * @since 9 604 */ 605 /** 606 * Called when scrolling begin each frame. 607 * 608 * @param { function } event 609 * @returns { ScrollAttribute } 610 * @syscap SystemCapability.ArkUI.ArkUI.Full 611 * @crossplatform 612 * @since 10 613 */ 614 onScrollFrameBegin(event: (offset: number, state: ScrollState) => { offsetRemain: number }): ScrollAttribute; 615 616 /** 617 * Called to setting the nested scroll options. 618 * 619 * @param { NestedScrollOptions } value - options for nested scrolling. 620 * @returns { ScrollAttribute } the attribute of the scroll. 621 * @syscap SystemCapability.ArkUI.ArkUI.Full 622 * @since 10 623 */ 624 nestedScroll(value: NestedScrollOptions): ScrollAttribute; 625 626 /** 627 * Called when setting whether to enable scroll by gesture or mouse. 628 * 629 * @param { boolean } value 630 * @returns { ScrollAttribute } The attribute of the scroll 631 * @syscap SystemCapability.ArkUI.ArkUI.Full 632 * @crossplatform 633 * @since 10 634 */ 635 enableScrollInteraction(value: boolean): ScrollAttribute; 636 637 /** 638 * Called to setting the friction. 639 * 640 * @param { number | Resource } value - options for scrolling friction. 641 * @returns { ScrollAttribute } the attribute of the scroll. 642 * @syscap SystemCapability.ArkUI.ArkUI.Full 643 * @crossplatform 644 * @since 10 645 */ 646 friction(value: number | Resource): ScrollAttribute; 647 648 /** 649 * Called to setting the scroll snap options. 650 * 651 * @param { ScrollSnapOptions } value - options for scroll snap. 652 * @returns { ScrollAttribute } the attribute of the scroll. 653 * @syscap SystemCapability.ArkUI.ArkUI.Full 654 * @since 10 655 */ 656 scrollSnap(value: ScrollSnapOptions): ScrollAttribute; 657} 658 659/** 660 * Defines Scroll Component. 661 * 662 * @syscap SystemCapability.ArkUI.ArkUI.Full 663 * @since 7 664 */ 665/** 666 * Defines Scroll Component. 667 * 668 * @syscap SystemCapability.ArkUI.ArkUI.Full 669 * @crossplatform 670 * @since 10 671 */ 672declare const Scroll: ScrollInterface; 673 674/** 675 * Defines Scroll Component instance. 676 * 677 * @syscap SystemCapability.ArkUI.ArkUI.Full 678 * @since 7 679 */ 680/** 681 * Defines Scroll Component instance. 682 * 683 * @syscap SystemCapability.ArkUI.ArkUI.Full 684 * @crossplatform 685 * @since 10 686 */ 687declare const ScrollInstance: ScrollAttribute; 688