You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scrollbar.d.ts 3.6 KiB

3 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { Options } from './options';
  2. import { TrackController } from './track/';
  3. import * as I from './interfaces/';
  4. export declare const scrollbarMap: Map<HTMLElement, Scrollbar>;
  5. export declare class Scrollbar implements I.Scrollbar {
  6. /**
  7. * Options for current scrollbar instancs
  8. */
  9. readonly options: Options;
  10. readonly track: TrackController;
  11. /**
  12. * The element that you initialized scrollbar to
  13. */
  14. readonly containerEl: HTMLElement;
  15. /**
  16. * The wrapper element that contains your contents
  17. */
  18. readonly contentEl: HTMLElement;
  19. /**
  20. * Geometry infomation for current scrollbar instance
  21. */
  22. size: I.ScrollbarSize;
  23. /**
  24. * Current scrolling offsets
  25. */
  26. offset: {
  27. x: number;
  28. y: number;
  29. };
  30. /**
  31. * Max-allowed scrolling offsets
  32. */
  33. limit: {
  34. x: number;
  35. y: number;
  36. };
  37. /**
  38. * Container bounding rect
  39. */
  40. bounding: {
  41. top: number;
  42. right: number;
  43. bottom: number;
  44. left: number;
  45. };
  46. /**
  47. * Parent scrollbar
  48. */
  49. readonly parent: Scrollbar | null;
  50. /**
  51. * Gets or sets `scrollbar.offset.y`
  52. */
  53. scrollTop: number;
  54. /**
  55. * Gets or sets `scrollbar.offset.x`
  56. */
  57. scrollLeft: number;
  58. private _renderID;
  59. private _observer;
  60. private _plugins;
  61. private _momentum;
  62. private _listeners;
  63. constructor(containerEl: HTMLElement, options?: Partial<I.ScrollbarOptions>);
  64. /**
  65. * Returns the size of the scrollbar container element
  66. * and the content wrapper element
  67. */
  68. getSize(): I.ScrollbarSize;
  69. /**
  70. * Forces scrollbar to update geometry infomation.
  71. *
  72. * By default, scrollbars are automatically updated with `100ms` debounce (or `MutationObserver` fires).
  73. * You can call this method to force an update when you modified contents
  74. */
  75. update(): void;
  76. /**
  77. * Checks if an element is visible in the current view area
  78. */
  79. isVisible(elem: HTMLElement): boolean;
  80. /**
  81. * Sets the scrollbar to the given offset without easing
  82. */
  83. setPosition(x?: number, y?: number, options?: Partial<I.SetPositionOptions>): void;
  84. /**
  85. * Scrolls to given position with easing function
  86. */
  87. scrollTo(x?: number, y?: number, duration?: number, options?: Partial<I.ScrollToOptions>): void;
  88. /**
  89. * Scrolls the target element into visible area of scrollbar,
  90. * likes the DOM method `element.scrollIntoView().
  91. */
  92. scrollIntoView(elem: HTMLElement, options?: Partial<I.ScrollIntoViewOptions>): void;
  93. /**
  94. * Adds scrolling listener
  95. */
  96. addListener(fn: I.ScrollListener): void;
  97. /**
  98. * Removes listener previously registered with `scrollbar.addListener()`
  99. */
  100. removeListener(fn: I.ScrollListener): void;
  101. /**
  102. * Adds momentum and applys delta transformers.
  103. */
  104. addTransformableMomentum(x: number, y: number, fromEvent: Event, callback?: I.AddTransformableMomentumCallback): void;
  105. /**
  106. * Increases scrollbar's momentum
  107. */
  108. addMomentum(x: number, y: number): void;
  109. /**
  110. * Sets scrollbar's momentum to given value
  111. */
  112. setMomentum(x: number, y: number): void;
  113. /**
  114. * Update options for specific plugin
  115. *
  116. * @param pluginName Name of the plugin
  117. * @param [options] An object includes the properties that you want to update
  118. */
  119. updatePluginOptions(pluginName: string, options?: any): void;
  120. destroy(): void;
  121. private _init;
  122. private _updateDebounced;
  123. private _shouldPropagateMomentum;
  124. private _render;
  125. private _nextTick;
  126. }