foundation.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * @license
  3. * Copyright 2018 Google Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. import { MDCFoundation } from '@material/base/foundation';
  24. import { MDCTabScrollerAdapter } from './adapter';
  25. import { MDCTabScrollerRTL } from './rtl-scroller';
  26. /** MDC Tab Scroller Foundation */
  27. export declare class MDCTabScrollerFoundation extends MDCFoundation<MDCTabScrollerAdapter> {
  28. static get cssClasses(): {
  29. ANIMATING: string;
  30. SCROLL_AREA_SCROLL: string;
  31. SCROLL_TEST: string;
  32. };
  33. static get strings(): {
  34. AREA_SELECTOR: string;
  35. CONTENT_SELECTOR: string;
  36. };
  37. static get defaultAdapter(): MDCTabScrollerAdapter;
  38. /**
  39. * Controls whether we should handle the transitionend and interaction events
  40. * during the animation.
  41. */
  42. private isAnimating;
  43. /**
  44. * The MDCTabScrollerRTL instance varies per browser and allows us to
  45. * encapsulate the peculiar browser behavior of RTL scrolling in its own
  46. * class.
  47. */
  48. private rtlScrollerInstance?;
  49. constructor(adapter?: Partial<MDCTabScrollerAdapter>);
  50. init(): void;
  51. /**
  52. * Computes the current visual scroll position
  53. */
  54. getScrollPosition(): number;
  55. /**
  56. * Handles interaction events that occur during transition
  57. */
  58. handleInteraction(): void;
  59. /**
  60. * Handles the transitionend event
  61. */
  62. handleTransitionEnd(evt: Event): void;
  63. /**
  64. * Increment the scroll value by the scrollXIncrement using animation.
  65. * @param scrollXIncrement The value by which to increment the scroll position
  66. */
  67. incrementScroll(scrollXIncrement: number): void;
  68. /**
  69. * Increment the scroll value by the scrollXIncrement without animation.
  70. * @param scrollXIncrement The value by which to increment the scroll position
  71. */
  72. incrementScrollImmediate(scrollXIncrement: number): void;
  73. /**
  74. * Scrolls to the given scrollX value
  75. */
  76. scrollTo(scrollX: number): void;
  77. /**
  78. * @return Browser-specific {@link MDCTabScrollerRTL} instance.
  79. */
  80. getRTLScroller(): MDCTabScrollerRTL;
  81. /**
  82. * @return translateX value from a CSS matrix transform function string.
  83. */
  84. private calculateCurrentTranslateX;
  85. /**
  86. * Calculates a safe scroll value that is > 0 and < the max scroll value
  87. * @param scrollX The distance to scroll
  88. */
  89. private clampScrollValue;
  90. private computeCurrentScrollPositionRTL;
  91. private calculateScrollEdges;
  92. /**
  93. * Internal scroll method
  94. * @param scrollX The new scroll position
  95. */
  96. private scrollToImpl;
  97. /**
  98. * Internal RTL scroll method
  99. * @param scrollX The new scroll position
  100. */
  101. private scrollToImplRTL;
  102. /**
  103. * Internal method to compute the increment scroll operation values.
  104. * @param scrollX The desired scroll position increment
  105. * @return MDCTabScrollerAnimation with the sanitized values for performing
  106. * the scroll operation.
  107. */
  108. private getIncrementScrollOperation;
  109. /**
  110. * Animates the tab scrolling
  111. * @param animation The animation to apply
  112. */
  113. private animate;
  114. /**
  115. * Stops scroll animation
  116. */
  117. private stopScrollAnimation;
  118. /**
  119. * Gets the current scroll position during animation
  120. */
  121. private getAnimatingScrollPosition;
  122. /**
  123. * Determines the RTL Scroller to use
  124. */
  125. private rtlScrollerFactory;
  126. private isRTL;
  127. }
  128. export default MDCTabScrollerFoundation;