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 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * Content scroll direction. 23 * 24 * @enum { number } 25 * @syscap SystemCapability.ArkUI.ArkUI.Full 26 * @since 7 27 */ 28/** 29 * Content scroll direction. 30 * 31 * @enum { number } 32 * @syscap SystemCapability.ArkUI.ArkUI.Full 33 * @crossplatform 34 * @since 10 35 */ 36/** 37 * Content scroll direction. 38 * 39 * @enum { number } 40 * @syscap SystemCapability.ArkUI.ArkUI.Full 41 * @crossplatform 42 * @atomicservice 43 * @since 11 44 */ 45declare enum ScrollDirection { 46 /** 47 * Vertical scrolling is supported. 48 * 49 * @syscap SystemCapability.ArkUI.ArkUI.Full 50 * @since 7 51 */ 52 /** 53 * Vertical scrolling is supported. 54 * 55 * @syscap SystemCapability.ArkUI.ArkUI.Full 56 * @crossplatform 57 * @since 10 58 */ 59 /** 60 * Vertical scrolling is supported. 61 * 62 * @syscap SystemCapability.ArkUI.ArkUI.Full 63 * @crossplatform 64 * @atomicservice 65 * @since 11 66 */ 67 Vertical, 68 69 /** 70 * Horizontal scrolling is supported. 71 * 72 * @syscap SystemCapability.ArkUI.ArkUI.Full 73 * @since 7 74 */ 75 /** 76 * Horizontal scrolling is supported. 77 * 78 * @syscap SystemCapability.ArkUI.ArkUI.Full 79 * @crossplatform 80 * @since 10 81 */ 82 /** 83 * Horizontal scrolling is supported. 84 * 85 * @syscap SystemCapability.ArkUI.ArkUI.Full 86 * @crossplatform 87 * @atomicservice 88 * @since 11 89 */ 90 Horizontal, 91 92 /** 93 * Free scrolling is supported. 94 * 95 * @syscap SystemCapability.ArkUI.ArkUI.Full 96 * @since 7 97 * @deprecated since 9 98 */ 99 Free, 100 101 /** 102 * Non-scrollable. 103 * 104 * @syscap SystemCapability.ArkUI.ArkUI.Full 105 * @since 7 106 */ 107 /** 108 * Non-scrollable. 109 * 110 * @syscap SystemCapability.ArkUI.ArkUI.Full 111 * @crossplatform 112 * @since 10 113 */ 114 /** 115 * Non-scrollable. 116 * 117 * @syscap SystemCapability.ArkUI.ArkUI.Full 118 * @crossplatform 119 * @atomicservice 120 * @since 11 121 */ 122 None, 123} 124 125/** 126 * ScrollAlign. 127 * 128 * @enum { number } ScrollAlign 129 * @syscap SystemCapability.ArkUI.ArkUI.Full 130 * @crossplatform 131 * @since 10 132 */ 133/** 134 * ScrollAlign. 135 * 136 * @enum { number } ScrollAlign 137 * @syscap SystemCapability.ArkUI.ArkUI.Full 138 * @crossplatform 139 * @atomicservice 140 * @since 11 141 */ 142declare enum ScrollAlign { 143 /** 144 * Start position alignment. 145 * 146 * @syscap SystemCapability.ArkUI.ArkUI.Full 147 * @crossplatform 148 * @since 10 149 */ 150 /** 151 * Start position alignment. 152 * 153 * @syscap SystemCapability.ArkUI.ArkUI.Full 154 * @crossplatform 155 * @atomicservice 156 * @since 11 157 */ 158 START, 159 160 /** 161 * Center alignment. 162 * 163 * @syscap SystemCapability.ArkUI.ArkUI.Full 164 * @crossplatform 165 * @since 10 166 */ 167 /** 168 * Center alignment. 169 * 170 * @syscap SystemCapability.ArkUI.ArkUI.Full 171 * @crossplatform 172 * @atomicservice 173 * @since 11 174 */ 175 CENTER, 176 177 /** 178 * End position alignment. 179 * 180 * @syscap SystemCapability.ArkUI.ArkUI.Full 181 * @crossplatform 182 * @since 10 183 */ 184 /** 185 * End position alignment. 186 * 187 * @syscap SystemCapability.ArkUI.ArkUI.Full 188 * @crossplatform 189 * @atomicservice 190 * @since 11 191 */ 192 END, 193 194 /** 195 * Scroll the minimum distance to fully display the specified item. 196 * 197 * @syscap SystemCapability.ArkUI.ArkUI.Full 198 * @crossplatform 199 * @since 10 200 */ 201 /** 202 * Scroll the minimum distance to fully display the specified item. 203 * 204 * @syscap SystemCapability.ArkUI.ArkUI.Full 205 * @crossplatform 206 * @atomicservice 207 * @since 11 208 */ 209 AUTO, 210} 211 212/** 213 * OffsetResult info. 214 * 215 * @interface OffsetResult 216 * @syscap SystemCapability.ArkUI.ArkUI.Full 217 * @crossplatform 218 * @atomicservice 219 * @since 11 220 */ 221declare interface OffsetResult { 222 /** 223 * The X-axis offset. 224 * 225 * @type { number } 226 * @syscap SystemCapability.ArkUI.ArkUI.Full 227 * @crossplatform 228 * @atomicservice 229 * @since 11 230 */ 231 xOffset: number; 232 233 /** 234 * The y-axis offset. 235 * 236 * @type { number } 237 * @syscap SystemCapability.ArkUI.ArkUI.Full 238 * @crossplatform 239 * @atomicservice 240 * @since 11 241 */ 242 yOffset: number; 243} 244 245/** 246 * Define scroll edge options 247 * 248 * @interface ScrollEdgeOptions 249 * @syscap SystemCapability.ArkUI.ArkUI.Full 250 * @crossplatform 251 * @atomicservice 252 * @since 12 253 */ 254declare interface ScrollEdgeOptions { 255 /** 256 * The fasten speed of scrolling to the edge, unit is vp/s. 257 * 258 * @type { ?number } 259 * @syscap SystemCapability.ArkUI.ArkUI.Full 260 * @crossplatform 261 * @atomicservice 262 * @since 12 263 */ 264 velocity?: number; 265} 266 267/** 268 * Define scrollToIndex options 269 * 270 * @interface ScrollToIndexOptions 271 * @syscap SystemCapability.ArkUI.ArkUI.Full 272 * @crossplatform 273 * @atomicservice 274 * @since 12 275 */ 276declare interface ScrollToIndexOptions { 277 /** 278 * The extra offset of scrolling to the index, unit is vp. 279 * 280 * @type { ?LengthMetrics } 281 * @syscap SystemCapability.ArkUI.ArkUI.Full 282 * @crossplatform 283 * @atomicservice 284 * @since 12 285 */ 286 extraOffset?: LengthMetrics; 287} 288 289/** 290 * Provides custom animation parameters. 291 * 292 * @interface ScrollAnimationOptions 293 * @syscap SystemCapability.ArkUI.ArkUI.Full 294 * @crossplatform 295 * @atomicservice 296 * @since 12 297 */ 298declare interface ScrollAnimationOptions { 299 /** 300 * Set the duration of the animation. 301 * 302 * @type { ?number } 303 * @syscap SystemCapability.ArkUI.ArkUI.Full 304 * @crossplatform 305 * @atomicservice 306 * @since 12 307 */ 308 duration?: number; 309 310 /** 311 * Set the curve of the animation. 312 * 313 * @type { ?(Curve | ICurve) } 314 * @syscap SystemCapability.ArkUI.ArkUI.Full 315 * @crossplatform 316 * @atomicservice 317 * @since 12 318 */ 319 curve?: Curve | ICurve; 320 321 /** 322 * Set whether the animation can over the boundary. 323 * 324 * @type { ?boolean } 325 * @default false 326 * @syscap SystemCapability.ArkUI.ArkUI.Full 327 * @crossplatform 328 * @atomicservice 329 * @since 12 330 */ 331 canOverScroll?: boolean; 332} 333 334/** 335 * OffsetOptions info. 336 * 337 * @interface OffsetOptions 338 * @syscap SystemCapability.ArkUI.ArkUI.Full 339 * @crossplatform 340 * @atomicservice 341 * @since 12 342 */ 343declare interface OffsetOptions { 344 /** 345 * The X-axis offset. 346 * 347 * @type { ?Dimension } 348 * @syscap SystemCapability.ArkUI.ArkUI.Full 349 * @crossplatform 350 * @atomicservice 351 * @since 12 352 */ 353 xOffset?: Dimension; 354 355 /** 356 * The y-axis offset. 357 * 358 * @type { ?Dimension } 359 * @syscap SystemCapability.ArkUI.ArkUI.Full 360 * @crossplatform 361 * @atomicservice 362 * @since 12 363 */ 364 yOffset?: Dimension; 365} 366 367/** 368 * Scroller 369 * 370 * @syscap SystemCapability.ArkUI.ArkUI.Full 371 * @since 7 372 */ 373/** 374 * Scroller 375 * 376 * @syscap SystemCapability.ArkUI.ArkUI.Full 377 * @crossplatform 378 * @since 10 379 */ 380/** 381 * Scroller 382 * 383 * @syscap SystemCapability.ArkUI.ArkUI.Full 384 * @crossplatform 385 * @atomicservice 386 * @since 11 387 */ 388declare class Scroller { 389 /** 390 * constructor. 391 * 392 * @syscap SystemCapability.ArkUI.ArkUI.Full 393 * @since 7 394 */ 395 /** 396 * constructor. 397 * 398 * @syscap SystemCapability.ArkUI.ArkUI.Full 399 * @crossplatform 400 * @since 10 401 */ 402 /** 403 * constructor. 404 * 405 * @syscap SystemCapability.ArkUI.ArkUI.Full 406 * @crossplatform 407 * @atomicservice 408 * @since 11 409 */ 410 constructor(); 411 412 /** 413 * Called when the setting slides to the specified position. 414 * 415 * @param { object } value 416 * @syscap SystemCapability.ArkUI.ArkUI.Full 417 * @since 7 418 */ 419 /** 420 * Called when the setting slides to the specified position. 421 * 422 * @param { object } value 423 * @syscap SystemCapability.ArkUI.ArkUI.Full 424 * @crossplatform 425 * @since 10 426 */ 427 /** 428 * Called when the setting slides to the specified position. 429 * 430 * @param { object } value 431 * @syscap SystemCapability.ArkUI.ArkUI.Full 432 * @crossplatform 433 * @atomicservice 434 * @since 11 435 */ 436 scrollTo(value: { 437 /** 438 * The X-axis offset. 439 * 440 * @type { number | string } 441 * @syscap SystemCapability.ArkUI.ArkUI.Full 442 * @crossplatform 443 * @since 10 444 */ 445 /** 446 * The X-axis offset. 447 * 448 * @type { number | string } 449 * @syscap SystemCapability.ArkUI.ArkUI.Full 450 * @crossplatform 451 * @atomicservice 452 * @since 11 453 */ 454 xOffset: number | string; 455 456 /** 457 * The Y-axis offset. 458 * 459 * @type { number | string } 460 * @syscap SystemCapability.ArkUI.ArkUI.Full 461 * @crossplatform 462 * @since 10 463 */ 464 /** 465 * The Y-axis offset. 466 * 467 * @type { number | string } 468 * @syscap SystemCapability.ArkUI.ArkUI.Full 469 * @crossplatform 470 * @atomicservice 471 * @since 11 472 */ 473 yOffset: number | string; 474 475 /** 476 * Descriptive animation. 477 * 478 * @type { ?({ duration?: number; curve?: Curve | ICurve } | boolean) } The object type provides custom animation parameters 479 * and the boolean type enables default spring animation. 480 * @syscap SystemCapability.ArkUI.ArkUI.Full 481 * @crossplatform 482 * @since 10 483 */ 484 /** 485 * Descriptive animation. 486 * 487 * @type { ?({ duration?: number; curve?: Curve | ICurve } | boolean) } The object type provides custom animation parameters 488 * and the boolean type enables default spring animation. 489 * @syscap SystemCapability.ArkUI.ArkUI.Full 490 * @crossplatform 491 * @atomicservice 492 * @since 11 493 */ 494 /** 495 * Descriptive animation. 496 * 497 * @type { ?( ScrollAnimationOptions | boolean) } The ScrollAnimationOptions type provides custom animation parameters 498 * and the boolean type enables default spring animation. 499 * @syscap SystemCapability.ArkUI.ArkUI.Full 500 * @crossplatform 501 * @atomicservice 502 * @since 12 503 */ 504 animation?: ScrollAnimationOptions | boolean; 505 }); 506 507 /** 508 * Called when scrolling to the edge of the container. 509 * 510 * @param { Edge } value 511 * @syscap SystemCapability.ArkUI.ArkUI.Full 512 * @since 7 513 */ 514 /** 515 * Called when scrolling to the edge of the container. 516 * 517 * @param { Edge } value 518 * @syscap SystemCapability.ArkUI.ArkUI.Full 519 * @crossplatform 520 * @since 10 521 */ 522 /** 523 * Called when scrolling to the edge of the container. 524 * 525 * @param { Edge } value 526 * @syscap SystemCapability.ArkUI.ArkUI.Full 527 * @crossplatform 528 * @atomicservice 529 * @since 11 530 */ 531 /** 532 * Called when scrolling to the edge of the container. 533 * 534 * @param { Edge } value - Edge type of the container. 535 * @param { ScrollEdgeOptions } [options] - Options of scrolling to edge. 536 * @syscap SystemCapability.ArkUI.ArkUI.Full 537 * @crossplatform 538 * @atomicservice 539 * @since 12 540 */ 541 scrollEdge(value: Edge, options?: ScrollEdgeOptions); 542 543 544 /** 545 * Fling the scroll view. 546 * 547 * @param { number } velocity - initial velocity of fling, in vp/s. 548 * @throws { BusinessError } 401 - Parameter error. Possible causes: 549 * <br> 1. Mandatory parameters are left unspecified. 550 * <br> 2. Incorrect parameters types. 551 * <br> 3. Parameter verification failed. 552 * @throws { BusinessError } 100004 - Controller not bound to component. 553 * @syscap SystemCapability.ArkUI.ArkUI.Full 554 * @crossplatform 555 * @atomicservice 556 * @since 12 557 */ 558 fling(velocity: number): void; 559 560 /** 561 * Called when page turning mode is set. 562 * 563 * @param { object } value 564 * @syscap SystemCapability.ArkUI.ArkUI.Full 565 * @since 9 566 */ 567 /** 568 * Called when page turning mode is set. 569 * 570 * @param { object } value 571 * @syscap SystemCapability.ArkUI.ArkUI.Full 572 * @crossplatform 573 * @since 10 574 */ 575 /** 576 * Called when page turning mode is set. 577 * 578 * @param { object } value 579 * @syscap SystemCapability.ArkUI.ArkUI.Full 580 * @crossplatform 581 * @atomicservice 582 * @since 11 583 */ 584 /** 585 * Called when page turning mode is set. 586 * 587 * @param { ScrollPageOptions } value 588 * @syscap SystemCapability.ArkUI.ArkUI.Full 589 * @crossplatform 590 * @atomicservice 591 * @since 14 592 */ 593 scrollPage(value: ScrollPageOptions); 594 595 /** 596 * Called when page turning mode is set. 597 * 598 * @param { object } value 599 * @syscap SystemCapability.ArkUI.ArkUI.Full 600 * @since 7 601 * @deprecated since 9 602 */ 603 scrollPage(value: { next: boolean; direction?: Axis }); 604 605 /** 606 * Called when viewing the scroll offset. 607 * 608 * @syscap SystemCapability.ArkUI.ArkUI.Full 609 * @since 7 610 */ 611 /** 612 * Called when viewing the scroll offset. 613 * 614 * @syscap SystemCapability.ArkUI.ArkUI.Full 615 * @crossplatform 616 * @since 10 617 */ 618 /** 619 * Called when viewing the scroll offset. 620 * 621 * @returns { OffsetResult } Returns the current scrolling offset. If the scroller not bound to a component, the return value is void. 622 * @syscap SystemCapability.ArkUI.ArkUI.Full 623 * @crossplatform 624 * @atomicservice 625 * @since 11 626 */ 627 currentOffset() : OffsetResult; 628 629 /** 630 * Called when sliding to the specified index. 631 * 632 * @param { number } value 633 * @param { boolean } smooth 634 * @param { ScrollAlign } align 635 * @syscap SystemCapability.ArkUI.ArkUI.Full 636 * @since 7 637 */ 638 /** 639 * Called when sliding to the specified index. 640 * 641 * @param { number } value - Index to jump to. 642 * @param { boolean } smooth - If true, scroll to index item with animation. If false, scroll to index item without animation. 643 * @param { ScrollAlign } align - Sets the alignment mode of a specified index. 644 * @syscap SystemCapability.ArkUI.ArkUI.Full 645 * @crossplatform 646 * @since 10 647 */ 648 /** 649 * Called when sliding to the specified index. 650 * 651 * @param { number } value - Index to jump to. 652 * @param { boolean } smooth - If true, scroll to index item with animation. If false, scroll to index item without animation. 653 * @param { ScrollAlign } align - Sets the alignment mode of a specified index. 654 * @syscap SystemCapability.ArkUI.ArkUI.Full 655 * @crossplatform 656 * @atomicservice 657 * @since 11 658 */ 659 /** 660 * Scroll to the specified index. 661 * 662 * @param { number } value - Index to jump to. 663 * @param { boolean } [smooth] - If true, scroll to index item with animation. If false, scroll to index item without animation. 664 * @param { ScrollAlign } [align] - Sets the alignment mode of a specified index. 665 * @param { ScrollToIndexOptions } [options] - Sets the options of a specified index, such as extra offset. 666 * @syscap SystemCapability.ArkUI.ArkUI.Full 667 * @crossplatform 668 * @atomicservice 669 * @since 12 670 */ 671 scrollToIndex(value: number, smooth?: boolean, align?: ScrollAlign, options?: ScrollToIndexOptions); 672 673 /** 674 * Called when the setting slides by offset. 675 * 676 * @param { Length } dx 677 * @param { Length } dy 678 * @syscap SystemCapability.ArkUI.ArkUI.Full 679 * @since 9 680 */ 681 /** 682 * Called when the setting slides by offset. 683 * 684 * @param { Length } dx 685 * @param { Length } dy 686 * @syscap SystemCapability.ArkUI.ArkUI.Full 687 * @crossplatform 688 * @since 10 689 */ 690 /** 691 * Called when the setting slides by offset. 692 * 693 * @param { Length } dx 694 * @param { Length } dy 695 * @syscap SystemCapability.ArkUI.ArkUI.Full 696 * @crossplatform 697 * @atomicservice 698 * @since 11 699 */ 700 scrollBy(dx: Length, dy: Length); 701 702 /** 703 * Indicates whether the component scrolls to the end position. 704 * 705 * @returns { boolean } Returns whether the component scrolls to the end position. 706 * @syscap SystemCapability.ArkUI.ArkUI.Full 707 * @crossplatform 708 * @since 10 709 */ 710 /** 711 * Indicates whether the component scrolls to the end position. 712 * 713 * @returns { boolean } Returns whether the component scrolls to the end position. 714 * @syscap SystemCapability.ArkUI.ArkUI.Full 715 * @crossplatform 716 * @atomicservice 717 * @since 11 718 */ 719 isAtEnd(): boolean; 720 721 /** 722 * Get child item size and position. 723 * 724 * @param { number } index - Index of the item. 725 * @returns { RectResult } Returns the size and position. 726 * @throws { BusinessError } 401 - Parameter error. Possible causes: 727 * <br> 1. Mandatory parameters are left unspecified. 728 * <br> 2. Incorrect parameters types. 729 * <br> 3. Parameter verification failed. 730 * @throws { BusinessError } 100004 - Controller not bound to component. 731 * @syscap SystemCapability.ArkUI.ArkUI.Full 732 * @crossplatform 733 * @since 11 734 */ 735 /** 736 * Get child item size and position. 737 * 738 * @param { number } index - Index of the item. 739 * @returns { RectResult } Returns the size and position. 740 * @throws { BusinessError } 401 - Parameter error. Possible causes: 741 * <br> 1. Mandatory parameters are left unspecified. 742 * <br> 2. Incorrect parameters types. 743 * <br> 3. Parameter verification failed. 744 * @throws { BusinessError } 100004 - Controller not bound to component. 745 * @syscap SystemCapability.ArkUI.ArkUI.Full 746 * @crossplatform 747 * @atomicservice 748 * @since 12 749 */ 750 getItemRect(index: number): RectResult; 751 752 /** 753 * Get item index by position. 754 * 755 * @param { number } x - X coordinate relative to the upper left corner of the current component's original area, in vp. 756 * @param { number } y - Y coordinate relative to the upper left corner of the current component's original area, in vp. 757 * @returns { number } Index of the item. 758 * @throws { BusinessError } 401 - Parameter error. Possible causes: 759 * <br> 1. Mandatory parameters are left unspecified. 760 * <br> 2. Incorrect parameters types. 761 * <br> 3. Parameter verification failed. 762 * @throws { BusinessError } 100004 - The controller not bound to component. 763 * @syscap SystemCapability.ArkUI.ArkUI.Full 764 * @crossplatform 765 * @atomicservice 766 * @since 14 767 */ 768 getItemIndex(x: number, y: number): number; 769} 770 771/** 772 * Define scroll page options 773 * @interface ScrollPageOptions 774 * @syscap SystemCapability.ArkUI.ArkUI.Full 775 * @atomicservice 776 * @since 14 777 */ 778declare interface ScrollPageOptions { 779 /** 780 * Control whether to scroll to the next page or the previous page. 781 * 782 * @type { boolean } 783 * @syscap SystemCapability.ArkUI.ArkUI.Full 784 * @crossplatform 785 * @atomicservice 786 * @since 14 787 */ 788 next: boolean; 789 790 /** 791 * Set whether the scrollPage have animate. 792 * 793 * @type { ?boolean } 794 * @default false 795 * @syscap SystemCapability.ArkUI.ArkUI.Full 796 * @crossplatform 797 * @atomicservice 798 * @since 14 799 */ 800 animation?: boolean; 801} 802 803/** 804 * Define scroll snap options 805 * 806 * @interface ScrollSnapOptions 807 * @syscap SystemCapability.ArkUI.ArkUI.Full 808 * @since 10 809 */ 810/** 811 * Define scroll snap options 812 * 813 * @interface ScrollSnapOptions 814 * @syscap SystemCapability.ArkUI.ArkUI.Full 815 * @atomicservice 816 * @since 11 817 */ 818declare interface ScrollSnapOptions { 819 /** 820 * Set scroll snap alignment. 821 * 822 * @type { ScrollSnapAlign } 823 * @syscap SystemCapability.ArkUI.ArkUI.Full 824 * @since 10 825 */ 826 /** 827 * Set scroll snap alignment. 828 * 829 * @type { ScrollSnapAlign } 830 * @syscap SystemCapability.ArkUI.ArkUI.Full 831 * @atomicservice 832 * @since 11 833 */ 834 snapAlign: ScrollSnapAlign; 835 836 /** 837 * Set snap positions. When the type of snapPositions is Dimension, Scroll content is paginated by an integer 838 * multiple of snapPositions. When the type of snapPositions is Array<number>, Scroll content is paginated based 839 * on the array of snapPositions. 840 * 841 * @type { ?(Dimension | Array<Dimension>) } 842 * @default 100% 843 * @syscap SystemCapability.ArkUI.ArkUI.Full 844 * @since 10 845 */ 846 /** 847 * Set snap positions. When the type of snapPositions is Dimension, Scroll content is paginated by an integer 848 * multiple of snapPositions. When the type of snapPositions is Array<number>, Scroll content is paginated based 849 * on the array of snapPositions. 850 * 851 * @type { ?(Dimension | Array<Dimension>) } 852 * @default 100% 853 * @syscap SystemCapability.ArkUI.ArkUI.Full 854 * @atomicservice 855 * @since 11 856 */ 857 snapPagination?: Dimension | Array<Dimension>; 858 859 /** 860 * Set whether the beginning of the Scroll content counts an a snap. 861 * 862 * @type { ?boolean } 863 * @default true 864 * @syscap SystemCapability.ArkUI.ArkUI.Full 865 * @since 10 866 */ 867 /** 868 * Set whether the beginning of the Scroll content counts an a snap. 869 * 870 * @type { ?boolean } 871 * @default true 872 * @syscap SystemCapability.ArkUI.ArkUI.Full 873 * @atomicservice 874 * @since 11 875 */ 876 enableSnapToStart?: boolean; 877 878 /** 879 * Set whether the end of the Scroll content counts an a snap. 880 * 881 * @type { ?boolean } 882 * @default true 883 * @syscap SystemCapability.ArkUI.ArkUI.Full 884 * @since 10 885 */ 886 /** 887 * Set whether the end of the Scroll content counts an a snap. 888 * 889 * @type { ?boolean } 890 * @default true 891 * @syscap SystemCapability.ArkUI.ArkUI.Full 892 * @atomicservice 893 * @since 11 894 */ 895 enableSnapToEnd?: boolean; 896} 897 898/** 899 * Provides interfaces for scrollable containers. 900 * 901 * @interface ScrollInterface 902 * @syscap SystemCapability.ArkUI.ArkUI.Full 903 * @since 7 904 */ 905/** 906 * Provides interfaces for scrollable containers. 907 * 908 * @interface ScrollInterface 909 * @syscap SystemCapability.ArkUI.ArkUI.Full 910 * @crossplatform 911 * @since 10 912 */ 913/** 914 * Provides interfaces for scrollable containers. 915 * 916 * @interface ScrollInterface 917 * @syscap SystemCapability.ArkUI.ArkUI.Full 918 * @crossplatform 919 * @atomicservice 920 * @since 11 921 */ 922interface ScrollInterface { 923 /** 924 * Called when a scrollable container is set. 925 * 926 * @param { Scroller } scroller 927 * @returns { ScrollAttribute } 928 * @syscap SystemCapability.ArkUI.ArkUI.Full 929 * @since 7 930 */ 931 /** 932 * Called when a scrollable container is set. 933 * 934 * @param { Scroller } scroller 935 * @returns { ScrollAttribute } 936 * @syscap SystemCapability.ArkUI.ArkUI.Full 937 * @crossplatform 938 * @since 10 939 */ 940 /** 941 * Called when a scrollable container is set. 942 * 943 * @param { Scroller } scroller 944 * @returns { ScrollAttribute } 945 * @syscap SystemCapability.ArkUI.ArkUI.Full 946 * @crossplatform 947 * @atomicservice 948 * @since 11 949 */ 950 (scroller?: Scroller): ScrollAttribute; 951} 952 953/** 954 * Defines the scroll attribute functions. 955 * 956 * @extends CommonMethod<ScrollAttribute> 957 * @syscap SystemCapability.ArkUI.ArkUI.Full 958 * @since 7 959 */ 960/** 961 * Defines the scroll attribute functions. 962 * 963 * @extends CommonMethod<ScrollAttribute> 964 * @syscap SystemCapability.ArkUI.ArkUI.Full 965 * @crossplatform 966 * @since 10 967 */ 968/** 969 * Defines the scroll attribute functions. 970 * 971 * @extends ScrollableCommonMethod<ScrollAttribute> 972 * @syscap SystemCapability.ArkUI.ArkUI.Full 973 * @crossplatform 974 * @atomicservice 975 * @since 11 976 */ 977declare class ScrollAttribute extends ScrollableCommonMethod<ScrollAttribute> { 978 /** 979 * Called when the scroll method is slid. 980 * 981 * @param { ScrollDirection } value 982 * @returns { ScrollAttribute } 983 * @syscap SystemCapability.ArkUI.ArkUI.Full 984 * @since 7 985 */ 986 /** 987 * Called when the scroll method is slid. 988 * 989 * @param { ScrollDirection } value 990 * @returns { ScrollAttribute } 991 * @syscap SystemCapability.ArkUI.ArkUI.Full 992 * @crossplatform 993 * @since 10 994 */ 995 /** 996 * Called when the scroll method is slid. 997 * 998 * @param { ScrollDirection } value 999 * @returns { ScrollAttribute } 1000 * @syscap SystemCapability.ArkUI.ArkUI.Full 1001 * @crossplatform 1002 * @atomicservice 1003 * @since 11 1004 */ 1005 scrollable(value: ScrollDirection): ScrollAttribute; 1006 1007 /** 1008 * Called when the setting slides to the specified position. 1009 * 1010 * @param { function } event 1011 * @returns { ScrollAttribute } 1012 * @syscap SystemCapability.ArkUI.ArkUI.Full 1013 * @since 7 1014 */ 1015 /** 1016 * Called when the setting slides to the specified position. 1017 * 1018 * @param { function } event 1019 * @returns { ScrollAttribute } 1020 * @syscap SystemCapability.ArkUI.ArkUI.Full 1021 * @crossplatform 1022 * @since 10 1023 */ 1024 /** 1025 * Called when the setting slides to the specified position. 1026 * 1027 * @param { function } event 1028 * @returns { ScrollAttribute } 1029 * @syscap SystemCapability.ArkUI.ArkUI.Full 1030 * @crossplatform 1031 * @atomicservice 1032 * @since 11 1033 * @deprecated since 12 1034 * @useinstead scroll/Scroll#onWillScroll 1035 * 1036 */ 1037 onScroll(event: (xOffset: number, yOffset: number) => void): ScrollAttribute; 1038 1039 /** 1040 * Called when the Scroll will scroll. 1041 * 1042 * @param { ScrollOnWillScrollCallback } handler - callback of Scroll 1043 * @returns { ScrollAttribute } 1044 * @syscap SystemCapability.ArkUI.ArkUI.Full 1045 * @crossplatform 1046 * @atomicservice 1047 * @since 12 1048 */ 1049 onWillScroll(handler: ScrollOnWillScrollCallback): ScrollAttribute; 1050 1051 /** 1052 * Called when the Scroll did scroll. 1053 * 1054 * @param { ScrollOnScrollCallback } handler - callback of Scroll, 1055 * xOffset and yOffset are offsets this frame did scroll, scrollState is current scroll state. 1056 * @returns { ScrollAttribute } 1057 * @syscap SystemCapability.ArkUI.ArkUI.Full 1058 * @crossplatform 1059 * @atomicservice 1060 * @since 12 1061 */ 1062 onDidScroll(handler: ScrollOnScrollCallback): ScrollAttribute; 1063 1064 /** 1065 * Called when scrolling to the edge of the container. 1066 * 1067 * @param { function } event 1068 * @returns { ScrollAttribute } 1069 * @syscap SystemCapability.ArkUI.ArkUI.Full 1070 * @since 7 1071 */ 1072 /** 1073 * Called when scrolling to the edge of the container. 1074 * 1075 * @param { function } event 1076 * @returns { ScrollAttribute } 1077 * @syscap SystemCapability.ArkUI.ArkUI.Full 1078 * @crossplatform 1079 * @since 10 1080 */ 1081 /** 1082 * Called when scrolling to the edge of the container. 1083 * 1084 * @param { function } event 1085 * @returns { ScrollAttribute } 1086 * @syscap SystemCapability.ArkUI.ArkUI.Full 1087 * @crossplatform 1088 * @atomicservice 1089 * @since 11 1090 */ 1091 onScrollEdge(event: (side: Edge) => void): ScrollAttribute; 1092 1093 /** 1094 * Called when scrolling start. 1095 * 1096 * @param { function } event 1097 * @returns { ScrollAttribute } 1098 * @syscap SystemCapability.ArkUI.ArkUI.Full 1099 * @since 9 1100 */ 1101 /** 1102 * Called when scrolling start. 1103 * 1104 * @param { function } event 1105 * @returns { ScrollAttribute } 1106 * @syscap SystemCapability.ArkUI.ArkUI.Full 1107 * @crossplatform 1108 * @since 10 1109 */ 1110 /** 1111 * Called when scrolling start. 1112 * 1113 * @param { function } event 1114 * @returns { ScrollAttribute } 1115 * @syscap SystemCapability.ArkUI.ArkUI.Full 1116 * @crossplatform 1117 * @atomicservice 1118 * @since 11 1119 */ 1120 onScrollStart(event: () => void): ScrollAttribute; 1121 1122 /** 1123 * Called when scrolling has stopped. 1124 * 1125 * @param { function } event 1126 * @returns { ScrollAttribute } 1127 * @syscap SystemCapability.ArkUI.ArkUI.Full 1128 * @since 7 1129 * @deprecated since 9 1130 * @useinstead scroll/Scroll#onScrollStop 1131 */ 1132 onScrollEnd(event: () => void): ScrollAttribute; 1133 1134 /** 1135 * Called when scrolling has stopped. 1136 * 1137 * @param { function } event 1138 * @returns { ScrollAttribute } 1139 * @syscap SystemCapability.ArkUI.ArkUI.Full 1140 * @since 9 1141 */ 1142 /** 1143 * Called when scrolling has stopped. 1144 * 1145 * @param { function } event 1146 * @returns { ScrollAttribute } 1147 * @syscap SystemCapability.ArkUI.ArkUI.Full 1148 * @crossplatform 1149 * @since 10 1150 */ 1151 /** 1152 * Called when scrolling has stopped. 1153 * 1154 * @param { function } event 1155 * @returns { ScrollAttribute } 1156 * @syscap SystemCapability.ArkUI.ArkUI.Full 1157 * @crossplatform 1158 * @atomicservice 1159 * @since 11 1160 */ 1161 onScrollStop(event: () => void): ScrollAttribute; 1162 1163 /** 1164 * Called when the status of the scroll bar is set. 1165 * 1166 * @param { BarState } barState 1167 * @returns { ScrollAttribute } 1168 * @syscap SystemCapability.ArkUI.ArkUI.Full 1169 * @since 7 1170 */ 1171 /** 1172 * Called when the status of the scroll bar is set. 1173 * 1174 * @param { BarState } barState 1175 * @returns { ScrollAttribute } 1176 * @syscap SystemCapability.ArkUI.ArkUI.Full 1177 * @crossplatform 1178 * @since 10 1179 */ 1180 /** 1181 * Called when the status of the scroll bar is set. 1182 * 1183 * @param { BarState } barState 1184 * @returns { ScrollAttribute } 1185 * @syscap SystemCapability.ArkUI.ArkUI.Full 1186 * @crossplatform 1187 * @atomicservice 1188 * @since 11 1189 */ 1190 scrollBar(barState: BarState): ScrollAttribute; 1191 1192 /** 1193 * Called when the color of the scroll bar is set. 1194 * 1195 * @param { Color | number | string } color 1196 * @returns { ScrollAttribute } 1197 * @syscap SystemCapability.ArkUI.ArkUI.Full 1198 * @since 7 1199 */ 1200 /** 1201 * Called when the color of the scroll bar is set. 1202 * 1203 * @param { Color | number | string } color 1204 * @returns { ScrollAttribute } 1205 * @syscap SystemCapability.ArkUI.ArkUI.Full 1206 * @crossplatform 1207 * @since 10 1208 */ 1209 /** 1210 * Called when the color of the scroll bar is set. 1211 * 1212 * @param { Color | number | string } color 1213 * @returns { ScrollAttribute } 1214 * @syscap SystemCapability.ArkUI.ArkUI.Full 1215 * @crossplatform 1216 * @atomicservice 1217 * @since 11 1218 */ 1219 scrollBarColor(color: Color | number | string): ScrollAttribute; 1220 1221 /** 1222 * Called when the width of the scroll bar is set. 1223 * 1224 * @param { number | string } value 1225 * @returns { ScrollAttribute } 1226 * @syscap SystemCapability.ArkUI.ArkUI.Full 1227 * @since 7 1228 */ 1229 /** 1230 * Called when the width of the scroll bar is set. 1231 * 1232 * @param { number | string } value 1233 * @returns { ScrollAttribute } 1234 * @syscap SystemCapability.ArkUI.ArkUI.Full 1235 * @crossplatform 1236 * @since 10 1237 */ 1238 /** 1239 * Called when the width of the scroll bar is set. 1240 * 1241 * @param { number | string } value 1242 * @returns { ScrollAttribute } 1243 * @syscap SystemCapability.ArkUI.ArkUI.Full 1244 * @crossplatform 1245 * @atomicservice 1246 * @since 11 1247 */ 1248 scrollBarWidth(value: number | string): ScrollAttribute; 1249 1250 /** 1251 * Called when the sliding effect is set. 1252 * 1253 * @param { EdgeEffect } edgeEffect 1254 * @returns { ScrollAttribute } 1255 * @syscap SystemCapability.ArkUI.ArkUI.Full 1256 * @since 7 1257 */ 1258 /** 1259 * Called when the sliding effect is set. 1260 * 1261 * @param { EdgeEffect } edgeEffect 1262 * @returns { ScrollAttribute } 1263 * @syscap SystemCapability.ArkUI.ArkUI.Full 1264 * @crossplatform 1265 * @since 10 1266 */ 1267 /** 1268 * Called when the sliding effect is set. 1269 * 1270 * @param { EdgeEffect } edgeEffect 1271 * @param { EdgeEffectOptions } options 1272 * @returns { ScrollAttribute } 1273 * @syscap SystemCapability.ArkUI.ArkUI.Full 1274 * @crossplatform 1275 * @atomicservice 1276 * @since 11 1277 */ 1278 edgeEffect(edgeEffect: EdgeEffect, options?: EdgeEffectOptions): ScrollAttribute; 1279 1280 /** 1281 * Called when scrolling begin each frame. 1282 * 1283 * @param { function } event 1284 * @returns { ScrollAttribute } 1285 * @syscap SystemCapability.ArkUI.ArkUI.Full 1286 * @since 9 1287 */ 1288 /** 1289 * Called when scrolling begin each frame. 1290 * 1291 * @param { function } event 1292 * @returns { ScrollAttribute } 1293 * @syscap SystemCapability.ArkUI.ArkUI.Full 1294 * @crossplatform 1295 * @since 10 1296 */ 1297 /** 1298 * Called when scrolling begin each frame. 1299 * 1300 * @param { function } event 1301 * @returns { ScrollAttribute } 1302 * @syscap SystemCapability.ArkUI.ArkUI.Full 1303 * @crossplatform 1304 * @atomicservice 1305 * @since 11 1306 */ 1307 onScrollFrameBegin(event: (offset: number, state: ScrollState) => { offsetRemain: number }): ScrollAttribute; 1308 1309 /** 1310 * Called to setting the nested scroll options. 1311 * 1312 * @param { NestedScrollOptions } value - options for nested scrolling. 1313 * @returns { ScrollAttribute } the attribute of the scroll. 1314 * @syscap SystemCapability.ArkUI.ArkUI.Full 1315 * @since 10 1316 */ 1317 /** 1318 * Called to setting the nested scroll options. 1319 * 1320 * @param { NestedScrollOptions } value - options for nested scrolling. 1321 * @returns { ScrollAttribute } the attribute of the scroll. 1322 * @syscap SystemCapability.ArkUI.ArkUI.Full 1323 * @crossplatform 1324 * @atomicservice 1325 * @since 11 1326 */ 1327 nestedScroll(value: NestedScrollOptions): ScrollAttribute; 1328 1329 /** 1330 * Called when setting whether to enable scroll by gesture or mouse. 1331 * 1332 * @param { boolean } value 1333 * @returns { ScrollAttribute } The attribute of the scroll 1334 * @syscap SystemCapability.ArkUI.ArkUI.Full 1335 * @crossplatform 1336 * @since 10 1337 */ 1338 /** 1339 * Called when setting whether to enable scroll by gesture or mouse. 1340 * 1341 * @param { boolean } value 1342 * @returns { ScrollAttribute } The attribute of the scroll 1343 * @syscap SystemCapability.ArkUI.ArkUI.Full 1344 * @crossplatform 1345 * @atomicservice 1346 * @since 11 1347 */ 1348 enableScrollInteraction(value: boolean): ScrollAttribute; 1349 1350 /** 1351 * Called to setting the friction. 1352 * 1353 * @param { number | Resource } value - options for scrolling friction. 1354 * @returns { ScrollAttribute } the attribute of the scroll. 1355 * @syscap SystemCapability.ArkUI.ArkUI.Full 1356 * @crossplatform 1357 * @since 10 1358 */ 1359 /** 1360 * Called to setting the friction. 1361 * 1362 * @param { number | Resource } value - options for scrolling friction. 1363 * @returns { ScrollAttribute } the attribute of the scroll. 1364 * @syscap SystemCapability.ArkUI.ArkUI.Full 1365 * @crossplatform 1366 * @atomicservice 1367 * @since 11 1368 */ 1369 friction(value: number | Resource): ScrollAttribute; 1370 1371 /** 1372 * Called to setting the scroll snap options. 1373 * 1374 * @param { ScrollSnapOptions } value - options for scroll snap. 1375 * @returns { ScrollAttribute } the attribute of the scroll. 1376 * @syscap SystemCapability.ArkUI.ArkUI.Full 1377 * @since 10 1378 */ 1379 /** 1380 * Called to setting the scroll snap options. 1381 * 1382 * @param { ScrollSnapOptions } value - options for scroll snap. 1383 * @returns { ScrollAttribute } the attribute of the scroll. 1384 * @syscap SystemCapability.ArkUI.ArkUI.Full 1385 * @atomicservice 1386 * @since 11 1387 */ 1388 scrollSnap(value: ScrollSnapOptions): ScrollAttribute; 1389 1390 /** 1391 * Determines whether the scroll view stops on multiples of the content size when the user scrolls. 1392 * 1393 * @param { boolean } value - A boolean value determines whether paging is enabled for scroll. 1394 * @returns { ScrollAttribute } the attribute of the scroll. 1395 * @syscap SystemCapability.ArkUI.ArkUI.Full 1396 * @crossplatform 1397 * @since 11 1398 */ 1399 /** 1400 * Determines whether the scroll view stops on multiples of the content size when the user scrolls. 1401 * 1402 * @param { boolean } value - A boolean value determines whether paging is enabled for scroll. 1403 * @returns { ScrollAttribute } the attribute of the scroll. 1404 * @syscap SystemCapability.ArkUI.ArkUI.Full 1405 * @crossplatform 1406 * @atomicservice 1407 * @since 12 1408 */ 1409 enablePaging(value: boolean): ScrollAttribute; 1410 1411 /** 1412 * Called to setting the initial offset 1413 * 1414 * @param { OffsetOptions } value - options for scroll initial offset. 1415 * @returns { ScrollAttribute } the attribute of the scroll. 1416 * @syscap SystemCapability.ArkUI.ArkUI.Full 1417 * @crossplatform 1418 * @atomicservice 1419 * @since 12 1420 */ 1421 initialOffset(value: OffsetOptions): ScrollAttribute; 1422} 1423 1424/** 1425 * callback of Scroll, using in onDidScroll. 1426 * 1427 * @typedef { function } ScrollOnScrollCallback 1428 * @param { number } xOffset - horizontal offset this frame did scroll. 1429 * @param { number } yOffset - vertical offset this frame did scroll. 1430 * @param { ScrollState } scrollState - current scroll state. 1431 * @syscap SystemCapability.ArkUI.ArkUI.Full 1432 * @crossplatform 1433 * @atomicservice 1434 * @since 12 1435 */ 1436declare type ScrollOnScrollCallback = (xOffset: number, yOffset: number, scrollState: ScrollState) => void; 1437 1438/** 1439 * Called before scroll to allow developer to control real offset the Scroll can scroll. 1440 * 1441 * @typedef { function } ScrollOnWillScrollCallback 1442 * @param { number } xOffset - horizontal offset this frame will scroll, which may or may not be reached. 1443 * @param { number } yOffset - vertical offset this frame will scroll, which may or may not be reached. 1444 * @param { ScrollState } scrollState - current scroll state. 1445 * @param { ScrollSource } scrollSource - source of current scroll. 1446 * @returns { void | OffsetResult } the remain offset for the Scroll, 1447 * same as (xOffset, yOffset) when no OffsetResult is returned. 1448 * @syscap SystemCapability.ArkUI.ArkUI.Full 1449 * @crossplatform 1450 * @atomicservice 1451 * @since 12 1452 */ 1453declare type ScrollOnWillScrollCallback = 1454 (xOffset: number, yOffset: number, scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult; 1455 1456/** 1457 * Defines Scroll Component. 1458 * 1459 * @syscap SystemCapability.ArkUI.ArkUI.Full 1460 * @since 7 1461 */ 1462/** 1463 * Defines Scroll Component. 1464 * 1465 * @syscap SystemCapability.ArkUI.ArkUI.Full 1466 * @crossplatform 1467 * @since 10 1468 */ 1469/** 1470 * Defines Scroll Component. 1471 * 1472 * @syscap SystemCapability.ArkUI.ArkUI.Full 1473 * @crossplatform 1474 * @atomicservice 1475 * @since 11 1476 */ 1477declare const Scroll: ScrollInterface; 1478 1479/** 1480 * Defines Scroll Component instance. 1481 * 1482 * @syscap SystemCapability.ArkUI.ArkUI.Full 1483 * @since 7 1484 */ 1485/** 1486 * Defines Scroll Component instance. 1487 * 1488 * @syscap SystemCapability.ArkUI.ArkUI.Full 1489 * @crossplatform 1490 * @since 10 1491 */ 1492/** 1493 * Defines Scroll Component instance. 1494 * 1495 * @syscap SystemCapability.ArkUI.ArkUI.Full 1496 * @crossplatform 1497 * @atomicservice 1498 * @since 11 1499 */ 1500declare const ScrollInstance: ScrollAttribute; 1501