@materializecss/materialize 2.0.1-alpha → 2.0.3-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/Gruntfile.js +5 -2
  2. package/dist/css/materialize.css +1510 -288
  3. package/dist/css/materialize.min.css +2 -2
  4. package/dist/js/materialize.js +2782 -2688
  5. package/dist/js/materialize.min.js +2 -8967
  6. package/dist/js/materialize.min.js.map +1 -1
  7. package/dist/src/autocomplete.d.ts +143 -0
  8. package/dist/src/autocomplete.d.ts.map +1 -0
  9. package/dist/src/bounding.d.ts +7 -0
  10. package/dist/src/bounding.d.ts.map +1 -0
  11. package/dist/src/buttons.d.ts +65 -0
  12. package/dist/src/buttons.d.ts.map +1 -0
  13. package/dist/src/cards.d.ts +4 -0
  14. package/dist/src/cards.d.ts.map +1 -0
  15. package/dist/src/carousel.d.ts +131 -0
  16. package/dist/src/carousel.d.ts.map +1 -0
  17. package/dist/src/characterCounter.d.ts +37 -0
  18. package/dist/src/characterCounter.d.ts.map +1 -0
  19. package/dist/src/chips.d.ts +131 -0
  20. package/dist/src/chips.d.ts.map +1 -0
  21. package/dist/src/collapsible.d.ts +74 -0
  22. package/dist/src/collapsible.d.ts.map +1 -0
  23. package/dist/src/component.d.ts +74 -0
  24. package/dist/src/component.d.ts.map +1 -0
  25. package/dist/src/datepicker.d.ts +248 -0
  26. package/dist/src/datepicker.d.ts.map +1 -0
  27. package/dist/src/dropdown.d.ts +148 -0
  28. package/dist/src/dropdown.d.ts.map +1 -0
  29. package/dist/src/edges.d.ts +7 -0
  30. package/dist/src/edges.d.ts.map +1 -0
  31. package/dist/src/forms.d.ts +12 -0
  32. package/dist/src/forms.d.ts.map +1 -0
  33. package/dist/src/global.d.ts +60 -0
  34. package/dist/src/global.d.ts.map +1 -0
  35. package/dist/src/index.d.ts +27 -0
  36. package/dist/src/index.d.ts.map +1 -0
  37. package/dist/src/materialbox.d.ts +92 -0
  38. package/dist/src/materialbox.d.ts.map +1 -0
  39. package/dist/src/modal.d.ts +119 -0
  40. package/dist/src/modal.d.ts.map +1 -0
  41. package/dist/src/parallax.d.ts +40 -0
  42. package/dist/src/parallax.d.ts.map +1 -0
  43. package/dist/src/pushpin.d.ts +52 -0
  44. package/dist/src/pushpin.d.ts.map +1 -0
  45. package/dist/src/range.d.ts +41 -0
  46. package/dist/src/range.d.ts.map +1 -0
  47. package/dist/src/scrollspy.d.ts +62 -0
  48. package/dist/src/scrollspy.d.ts.map +1 -0
  49. package/dist/src/select.d.ts +77 -0
  50. package/dist/src/select.d.ts.map +1 -0
  51. package/dist/src/sidenav.d.ts +122 -0
  52. package/dist/src/sidenav.d.ts.map +1 -0
  53. package/dist/src/slider.d.ts +103 -0
  54. package/dist/src/slider.d.ts.map +1 -0
  55. package/dist/src/tabs.d.ts +80 -0
  56. package/dist/src/tabs.d.ts.map +1 -0
  57. package/dist/src/tapTarget.d.ts +59 -0
  58. package/dist/src/tapTarget.d.ts.map +1 -0
  59. package/dist/src/timepicker.d.ts +208 -0
  60. package/dist/src/timepicker.d.ts.map +1 -0
  61. package/dist/src/toasts.d.ts +90 -0
  62. package/dist/src/toasts.d.ts.map +1 -0
  63. package/dist/src/tooltip.d.ts +112 -0
  64. package/dist/src/tooltip.d.ts.map +1 -0
  65. package/dist/src/utils.d.ts +97 -0
  66. package/dist/src/utils.d.ts.map +1 -0
  67. package/dist/src/waves.d.ts +16 -0
  68. package/dist/src/waves.d.ts.map +1 -0
  69. package/package.json +4 -1
  70. package/sass/components/_cards.scss +1 -1
  71. package/sass/components/_collapsible.scss +0 -41
  72. package/sass/components/_global.scss +53 -2
  73. package/sass/components/_grid.scss +28 -47
  74. package/sass/components/_icons-material-design.scss +2 -1
  75. package/sass/components/_navbar.scss +30 -27
  76. package/sass/components/_pulse.scss +1 -0
  77. package/sass/components/_sidenav.scss +63 -45
  78. package/sass/components/_theme_variables.scss +29 -49
  79. package/sass/components/_typography.scss +2 -2
  80. package/sass/components/_variables.scss +2 -0
  81. package/sass/components/colors.module.scss +180 -0
  82. package/sass/components/forms/_input-fields.scss +4 -10
  83. package/sass/components/theme.dark.module.scss +32 -0
  84. package/sass/components/theme.light.module.scss +32 -0
  85. package/sass/components/tokens.module.scss +272 -0
  86. package/sass/components/typography.module.scss +150 -0
  87. package/sass/materialize.scss +6 -4
  88. package/src/autocomplete.ts +188 -94
  89. package/src/buttons.ts +225 -260
  90. package/src/cards.ts +5 -6
  91. package/src/carousel.ts +611 -542
  92. package/src/characterCounter.ts +50 -21
  93. package/src/chips.ts +152 -63
  94. package/src/collapsible.ts +97 -32
  95. package/src/component.ts +99 -10
  96. package/src/datepicker.ts +905 -726
  97. package/src/dropdown.ts +573 -484
  98. package/src/edges.ts +4 -4
  99. package/src/forms.ts +36 -24
  100. package/src/global.ts +57 -328
  101. package/src/index.ts +26 -0
  102. package/src/materialbox.ts +354 -298
  103. package/src/modal.ts +296 -211
  104. package/src/parallax.ts +129 -105
  105. package/src/pushpin.ts +148 -103
  106. package/src/range.ts +166 -150
  107. package/src/scrollspy.ts +214 -174
  108. package/src/select.ts +434 -398
  109. package/src/sidenav.ts +447 -381
  110. package/src/slider.ts +421 -362
  111. package/src/tabs.ts +276 -222
  112. package/src/tapTarget.ts +246 -213
  113. package/src/timepicker.ts +738 -614
  114. package/src/toasts.ts +254 -230
  115. package/src/tooltip.ts +315 -252
  116. package/src/utils.ts +271 -0
  117. package/src/waves.ts +10 -10
package/src/tooltip.ts CHANGED
@@ -1,283 +1,346 @@
1
- import { Component } from "./component";
2
- import { M } from "./global";
3
1
  import anim from "animejs";
4
- import { Bounding } from "./bounding";
5
2
 
6
- const _defaults = {
7
- exitDelay: 200,
8
- enterDelay: 0,
9
- //html: null,
10
- text: '',
11
- //unsafeHTML: null,
12
- margin: 5,
13
- inDuration: 250,
14
- outDuration: 200,
15
- position: 'bottom',
16
- transitionMovement: 10
17
- };
18
-
19
- export class Tooltip extends Component {
20
- isOpen: boolean;
21
- isHovered: boolean;
22
- isFocused: boolean;
23
- tooltipEl: HTMLElement;
24
- private _handleMouseEnterBound: any;
25
- private _handleMouseLeaveBound: any;
26
- private _handleFocusBound: any;
27
- private _handleBlurBound: any;
28
- private _exitDelayTimeout: string | number | NodeJS.Timeout;
29
- private _enterDelayTimeout: string | number | NodeJS.Timeout;
30
- xMovement: number;
31
- yMovement: number;
32
-
33
- constructor(el, options) {
34
- super(Tooltip, el, options);
35
- (this.el as any).M_Tooltip = this;
36
- this.options = {...Tooltip.defaults, ...options};
37
- this.isOpen = false;
38
- this.isHovered = false;
39
- this.isFocused = false;
40
- this._appendTooltipEl();
41
- this._setupEventHandlers();
42
- }
3
+ import { Utils } from "./utils";
4
+ import { Bounding } from "./bounding";
5
+ import { Component, BaseOptions, InitElements, MElement } from "./component";
6
+
7
+ export interface TooltipOptions extends BaseOptions {
8
+ /**
9
+ * Delay time before tooltip disappears.
10
+ * @default 200
11
+ */
12
+ exitDelay: number;
13
+ /**
14
+ * Delay time before tooltip appears.
15
+ * @default 0
16
+ */
17
+ enterDelay: number;
18
+ /**
19
+ * Text string for the tooltip.
20
+ * @default ""
21
+ */
22
+ text: string;
23
+ /**
24
+ * Set distance tooltip appears away from its activator
25
+ * excluding transitionMovement.
26
+ * @default 5
27
+ */
28
+ margin: number;
29
+ /**
30
+ * Enter transition duration.
31
+ * @default 300
32
+ */
33
+ inDuration: number;
34
+ /**
35
+ * Opacity of the tooltip.
36
+ * @default 1
37
+ */
38
+ opacity: number;
39
+ /**
40
+ * Exit transition duration.
41
+ * @default 250
42
+ */
43
+ outDuration: number;
44
+ /**
45
+ * Set the direction of the tooltip.
46
+ * @default 'bottom'
47
+ */
48
+ position: 'top' | 'right' | 'bottom' | 'left';
49
+ /**
50
+ * Amount in px that the tooltip moves during its transition.
51
+ * @default 10
52
+ */
53
+ transitionMovement: number;
54
+ }
55
+
56
+ const _defaults: TooltipOptions = {
57
+ exitDelay: 200,
58
+ enterDelay: 0,
59
+ text: '',
60
+ margin: 5,
61
+ inDuration: 250,
62
+ outDuration: 200,
63
+ position: 'bottom',
64
+ transitionMovement: 10,
65
+ opacity: 1
66
+ };
67
+
68
+ export class Tooltip extends Component<TooltipOptions> {
69
+ /**
70
+ * If tooltip is open.
71
+ */
72
+ isOpen: boolean;
73
+ /**
74
+ * If tooltip is hovered.
75
+ */
76
+ isHovered: boolean;
77
+ /**
78
+ * If tooltip is focused.
79
+ */
80
+ isFocused: boolean;
81
+ tooltipEl: HTMLElement;
82
+ private _exitDelayTimeout: string | number | NodeJS.Timeout;
83
+ private _enterDelayTimeout: string | number | NodeJS.Timeout;
84
+ xMovement: number;
85
+ yMovement: number;
86
+
87
+ constructor(el: HTMLElement, options: Partial<TooltipOptions>) {
88
+ super(el, options, Tooltip);
89
+ (this.el as any).M_Tooltip = this;
90
+
91
+ this.options = {
92
+ ...Tooltip.defaults,
93
+ ...options
94
+ };
95
+
96
+ this.isOpen = false;
97
+ this.isHovered = false;
98
+ this.isFocused = false;
99
+ this._appendTooltipEl();
100
+ this._setupEventHandlers();
101
+ }
43
102
 
44
- static get defaults() {
45
- return _defaults;
46
- }
103
+ static get defaults(): TooltipOptions {
104
+ return _defaults;
105
+ }
47
106
 
48
- static init(els, options) {
49
- return super.init(this, els, options);
50
- }
107
+ /**
108
+ * Initializes instance of Tooltip.
109
+ * @param el HTML element.
110
+ * @param options Component options.
111
+ */
112
+ static init(el: HTMLElement, options?: Partial<TooltipOptions>): Tooltip;
113
+ /**
114
+ * Initializes instances of Tooltip.
115
+ * @param els HTML elements.
116
+ * @param options Component options.
117
+ */
118
+ static init(els: InitElements<MElement>, options?: Partial<TooltipOptions>): Tooltip[];
119
+ /**
120
+ * Initializes instances of Tooltip.
121
+ * @param els HTML elements.
122
+ * @param options Component options.
123
+ */
124
+ static init(els: HTMLElement | InitElements<MElement>, options: Partial<TooltipOptions> = {}): Tooltip | Tooltip[] {
125
+ return super.init(els, options, Tooltip);
126
+ }
51
127
 
52
- static getInstance(el) {
53
- const domElem = !!el.jquery ? el[0] : el;
54
- return domElem.M_Tooltip;
55
- }
128
+ static getInstance(el: HTMLElement): Tooltip {
129
+ return (el as any).M_Tooltip;
130
+ }
56
131
 
57
- destroy() {
58
- this.tooltipEl.remove();
59
- this._removeEventHandlers();
60
- (this.el as any).M_Tooltip = undefined;
61
- }
132
+ destroy() {
133
+ this.tooltipEl.remove();
134
+ this._removeEventHandlers();
135
+ (this.el as any).M_Tooltip = undefined;
136
+ }
62
137
 
63
- _appendTooltipEl() {
64
- this.tooltipEl = document.createElement('div');
65
- this.tooltipEl.classList.add('material-tooltip');
138
+ _appendTooltipEl() {
139
+ this.tooltipEl = document.createElement('div');
140
+ this.tooltipEl.classList.add('material-tooltip');
66
141
 
67
- const tooltipContentEl = document.createElement('div');
68
- tooltipContentEl.classList.add('tooltip-content');
69
- this._setTooltipContent(tooltipContentEl);
70
- this.tooltipEl.appendChild(tooltipContentEl);
71
- document.body.appendChild(this.tooltipEl);
72
- }
142
+ const tooltipContentEl = document.createElement('div');
143
+ tooltipContentEl.classList.add('tooltip-content');
144
+ this._setTooltipContent(tooltipContentEl);
145
+ this.tooltipEl.appendChild(tooltipContentEl);
146
+ document.body.appendChild(this.tooltipEl);
147
+ }
73
148
 
74
- _setTooltipContent(tooltipContentEl: HTMLElement) {
75
- tooltipContentEl.innerText = this.options.text;
76
- /*
77
- if (!!this.options.html) {
78
- // Warn when using html
79
- console.warn(
80
- 'The html option is deprecated and will be removed in the future. See https://github.com/materializecss/materialize/pull/49'
81
- );
82
- $(tooltipContentEl).append(this.options.html);
83
- }
84
- if (!!this.options.unsafeHTML) {
85
- $(tooltipContentEl).append(this.options.unsafeHTML);
86
- }
87
- */
88
- }
149
+ _setTooltipContent(tooltipContentEl: HTMLElement) {
150
+ tooltipContentEl.innerText = this.options.text;
151
+ }
89
152
 
90
- _updateTooltipContent() {
91
- this._setTooltipContent(this.tooltipEl.querySelector('.tooltip-content'));
92
- }
153
+ _updateTooltipContent() {
154
+ this._setTooltipContent(this.tooltipEl.querySelector('.tooltip-content'));
155
+ }
93
156
 
94
- _setupEventHandlers() {
95
- this._handleMouseEnterBound = this._handleMouseEnter.bind(this);
96
- this._handleMouseLeaveBound = this._handleMouseLeave.bind(this);
97
- this._handleFocusBound = this._handleFocus.bind(this);
98
- this._handleBlurBound = this._handleBlur.bind(this);
99
- this.el.addEventListener('mouseenter', this._handleMouseEnterBound);
100
- this.el.addEventListener('mouseleave', this._handleMouseLeaveBound);
101
- this.el.addEventListener('focus', this._handleFocusBound, true);
102
- this.el.addEventListener('blur', this._handleBlurBound, true);
103
- }
157
+ _setupEventHandlers() {
158
+ this.el.addEventListener('mouseenter', this._handleMouseEnter);
159
+ this.el.addEventListener('mouseleave', this._handleMouseLeave);
160
+ this.el.addEventListener('focus', this._handleFocus, true);
161
+ this.el.addEventListener('blur', this._handleBlur, true);
162
+ }
104
163
 
105
- _removeEventHandlers() {
106
- this.el.removeEventListener('mouseenter', this._handleMouseEnterBound);
107
- this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound);
108
- this.el.removeEventListener('focus', this._handleFocusBound, true);
109
- this.el.removeEventListener('blur', this._handleBlurBound, true);
110
- }
164
+ _removeEventHandlers() {
165
+ this.el.removeEventListener('mouseenter', this._handleMouseEnter);
166
+ this.el.removeEventListener('mouseleave', this._handleMouseLeave);
167
+ this.el.removeEventListener('focus', this._handleFocus, true);
168
+ this.el.removeEventListener('blur', this._handleBlur, true);
169
+ }
111
170
 
112
- open(isManual) {
113
- if (this.isOpen) return;
114
- isManual = isManual === undefined ? true : undefined; // Default value true
115
- this.isOpen = true;
116
- // Update tooltip content with HTML attribute options
117
- this.options = {...this.options, ...this._getAttributeOptions()};
118
- this._updateTooltipContent();
119
- this._setEnterDelayTimeout(isManual);
120
- }
171
+ /**
172
+ * Show tooltip.
173
+ */
174
+ open = (isManual: boolean) => {
175
+ if (this.isOpen) return;
176
+ isManual = isManual === undefined ? true : undefined; // Default value true
177
+ this.isOpen = true;
178
+ // Update tooltip content with HTML attribute options
179
+ this.options = {...this.options, ...this._getAttributeOptions()};
180
+ this._updateTooltipContent();
181
+ this._setEnterDelayTimeout(isManual);
182
+ }
183
+
184
+ /**
185
+ * Hide tooltip.
186
+ */
187
+ close = () => {
188
+ if (!this.isOpen) return;
189
+ this.isHovered = false;
190
+ this.isFocused = false;
191
+ this.isOpen = false;
192
+ this._setExitDelayTimeout();
193
+ }
121
194
 
122
- close() {
123
- if (!this.isOpen) return;
124
- this.isHovered = false;
125
- this.isFocused = false;
126
- this.isOpen = false;
127
- this._setExitDelayTimeout();
128
- }
195
+ _setExitDelayTimeout() {
196
+ clearTimeout(this._exitDelayTimeout);
197
+ this._exitDelayTimeout = setTimeout(() => {
198
+ if (this.isHovered || this.isFocused) return;
199
+ this._animateOut();
200
+ }, this.options.exitDelay);
201
+ }
129
202
 
130
- _setExitDelayTimeout() {
131
- clearTimeout(this._exitDelayTimeout);
132
- this._exitDelayTimeout = setTimeout(() => {
133
- if (this.isHovered || this.isFocused) return;
134
- this._animateOut();
135
- }, this.options.exitDelay);
136
- }
203
+ _setEnterDelayTimeout(isManual) {
204
+ clearTimeout(this._enterDelayTimeout);
205
+ this._enterDelayTimeout = setTimeout(() => {
206
+ if (!this.isHovered && !this.isFocused && !isManual) return;
207
+ this._animateIn();
208
+ }, this.options.enterDelay);
209
+ }
137
210
 
138
- _setEnterDelayTimeout(isManual) {
139
- clearTimeout(this._enterDelayTimeout);
140
- this._enterDelayTimeout = setTimeout(() => {
141
- if (!this.isHovered && !this.isFocused && !isManual) return;
142
- this._animateIn();
143
- }, this.options.enterDelay);
211
+ _positionTooltip() {
212
+ const tooltip: HTMLElement = this.tooltipEl;
213
+ const origin = (this.el as HTMLElement),
214
+ originHeight = origin.offsetHeight,
215
+ originWidth = origin.offsetWidth,
216
+ tooltipHeight = tooltip.offsetHeight,
217
+ tooltipWidth = tooltip.offsetWidth,
218
+ margin = this.options.margin;
219
+
220
+ (this.xMovement = 0), (this.yMovement = 0);
221
+
222
+ let targetTop = origin.getBoundingClientRect().top + Utils.getDocumentScrollTop();
223
+ let targetLeft = origin.getBoundingClientRect().left + Utils.getDocumentScrollLeft();
224
+ if (this.options.position === 'top') {
225
+ targetTop += -tooltipHeight - margin;
226
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
227
+ this.yMovement = -this.options.transitionMovement;
228
+ } else if (this.options.position === 'right') {
229
+ targetTop += originHeight / 2 - tooltipHeight / 2;
230
+ targetLeft += originWidth + margin;
231
+ this.xMovement = this.options.transitionMovement;
232
+ } else if (this.options.position === 'left') {
233
+ targetTop += originHeight / 2 - tooltipHeight / 2;
234
+ targetLeft += -tooltipWidth - margin;
235
+ this.xMovement = -this.options.transitionMovement;
236
+ } else {
237
+ targetTop += originHeight + margin;
238
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
239
+ this.yMovement = this.options.transitionMovement;
144
240
  }
145
241
 
146
- _positionTooltip() {
147
- const tooltip: HTMLElement = this.tooltipEl;
148
- const origin = (this.el as HTMLElement),
149
- originHeight = origin.offsetHeight,
150
- originWidth = origin.offsetWidth,
151
- tooltipHeight = tooltip.offsetHeight,
152
- tooltipWidth = tooltip.offsetWidth,
153
- margin = this.options.margin;
154
-
155
- (this.xMovement = 0), (this.yMovement = 0);
156
-
157
- let targetTop = origin.getBoundingClientRect().top + M.getDocumentScrollTop();
158
- let targetLeft = origin.getBoundingClientRect().left + M.getDocumentScrollLeft();
159
- if (this.options.position === 'top') {
160
- targetTop += -tooltipHeight - margin;
161
- targetLeft += originWidth / 2 - tooltipWidth / 2;
162
- this.yMovement = -this.options.transitionMovement;
163
- } else if (this.options.position === 'right') {
164
- targetTop += originHeight / 2 - tooltipHeight / 2;
165
- targetLeft += originWidth + margin;
166
- this.xMovement = this.options.transitionMovement;
167
- } else if (this.options.position === 'left') {
168
- targetTop += originHeight / 2 - tooltipHeight / 2;
169
- targetLeft += -tooltipWidth - margin;
170
- this.xMovement = -this.options.transitionMovement;
171
- } else {
172
- targetTop += originHeight + margin;
173
- targetLeft += originWidth / 2 - tooltipWidth / 2;
174
- this.yMovement = this.options.transitionMovement;
175
- }
176
-
177
- const newCoordinates = this._repositionWithinScreen(
178
- targetLeft,
179
- targetTop,
180
- tooltipWidth,
181
- tooltipHeight
182
- );
183
-
184
- tooltip.style.top = newCoordinates.y+'px';
185
- tooltip.style.left = newCoordinates.x+'px';
186
- }
242
+ const newCoordinates = this._repositionWithinScreen(
243
+ targetLeft,
244
+ targetTop,
245
+ tooltipWidth,
246
+ tooltipHeight
247
+ );
187
248
 
188
- _repositionWithinScreen(x, y, width, height) {
189
- const scrollLeft = M.getDocumentScrollLeft();
190
- const scrollTop = M.getDocumentScrollTop();
191
- let newX = x - scrollLeft;
192
- let newY = y - scrollTop;
193
-
194
- const bounding: Bounding = {
195
- left: newX,
196
- top: newY,
197
- width: width,
198
- height: height
199
- };
200
- const offset = this.options.margin + this.options.transitionMovement;
201
- const edges = M.checkWithinContainer(document.body, bounding, offset);
202
-
203
- if (edges.left) {
204
- newX = offset;
205
- } else if (edges.right) {
206
- newX -= newX + width - window.innerWidth;
207
- }
208
- if (edges.top) {
209
- newY = offset;
210
- } else if (edges.bottom) {
211
- newY -= newY + height - window.innerHeight;
212
- }
213
- return {
214
- x: newX + scrollLeft,
215
- y: newY + scrollTop
216
- };
217
- }
249
+ tooltip.style.top = newCoordinates.y+'px';
250
+ tooltip.style.left = newCoordinates.x+'px';
251
+ }
218
252
 
219
- _animateIn() {
220
- this._positionTooltip();
221
- this.tooltipEl.style.visibility = 'visible';
222
- anim.remove(this.tooltipEl);
223
- anim({
224
- targets: this.tooltipEl,
225
- opacity: this.options.opacity || 1,
226
- translateX: this.xMovement,
227
- translateY: this.yMovement,
228
- duration: this.options.inDuration,
229
- easing: 'easeOutCubic'
230
- });
253
+ _repositionWithinScreen(x: number, y: number, width: number, height: number) {
254
+ const scrollLeft = Utils.getDocumentScrollLeft();
255
+ const scrollTop = Utils.getDocumentScrollTop();
256
+ let newX = x - scrollLeft;
257
+ let newY = y - scrollTop;
258
+
259
+ const bounding: Bounding = {
260
+ left: newX,
261
+ top: newY,
262
+ width: width,
263
+ height: height
264
+ };
265
+ const offset = this.options.margin + this.options.transitionMovement;
266
+ const edges = Utils.checkWithinContainer(document.body, bounding, offset);
267
+
268
+ if (edges.left) {
269
+ newX = offset;
270
+ } else if (edges.right) {
271
+ newX -= newX + width - window.innerWidth;
231
272
  }
232
-
233
- _animateOut() {
234
- anim.remove(this.tooltipEl);
235
- anim({
236
- targets: this.tooltipEl,
237
- opacity: 0,
238
- translateX: 0,
239
- translateY: 0,
240
- duration: this.options.outDuration,
241
- easing: 'easeOutCubic'
242
- });
273
+ if (edges.top) {
274
+ newY = offset;
275
+ } else if (edges.bottom) {
276
+ newY -= newY + height - window.innerHeight;
243
277
  }
278
+ return {
279
+ x: newX + scrollLeft,
280
+ y: newY + scrollTop
281
+ };
282
+ }
244
283
 
245
- _handleMouseEnter() {
246
- this.isHovered = true;
247
- this.isFocused = false; // Allows close of tooltip when opened by focus.
248
- this.open(false);
249
- }
284
+ _animateIn() {
285
+ this._positionTooltip();
286
+ this.tooltipEl.style.visibility = 'visible';
287
+ anim.remove(this.tooltipEl);
288
+ anim({
289
+ targets: this.tooltipEl,
290
+ opacity: this.options.opacity || 1,
291
+ translateX: this.xMovement,
292
+ translateY: this.yMovement,
293
+ duration: this.options.inDuration,
294
+ easing: 'easeOutCubic'
295
+ });
296
+ }
250
297
 
251
- _handleMouseLeave() {
252
- this.isHovered = false;
253
- this.isFocused = false; // Allows close of tooltip when opened by focus.
254
- this.close();
255
- }
298
+ _animateOut() {
299
+ anim.remove(this.tooltipEl);
300
+ anim({
301
+ targets: this.tooltipEl,
302
+ opacity: 0,
303
+ translateX: 0,
304
+ translateY: 0,
305
+ duration: this.options.outDuration,
306
+ easing: 'easeOutCubic'
307
+ });
308
+ }
256
309
 
257
- _handleFocus() {
258
- if (M.tabPressed) {
259
- this.isFocused = true;
260
- this.open(false);
261
- }
262
- }
310
+ _handleMouseEnter = () => {
311
+ this.isHovered = true;
312
+ this.isFocused = false; // Allows close of tooltip when opened by focus.
313
+ this.open(false);
314
+ }
263
315
 
264
- _handleBlur() {
265
- this.isFocused = false;
266
- this.close();
267
- }
316
+ _handleMouseLeave = () => {
317
+ this.isHovered = false;
318
+ this.isFocused = false; // Allows close of tooltip when opened by focus.
319
+ this.close();
320
+ }
268
321
 
269
- _getAttributeOptions() {
270
- const attributeOptions = {};
271
- const tooltipTextOption = this.el.getAttribute('data-tooltip');
272
- const positionOption = this.el.getAttribute('data-position');
273
- if (tooltipTextOption) {
274
- (attributeOptions as any).text = tooltipTextOption;
275
- }
276
- if (positionOption) {
277
- (attributeOptions as any).position = positionOption;
278
- }
279
- return attributeOptions;
322
+ _handleFocus = () => {
323
+ if (Utils.tabPressed) {
324
+ this.isFocused = true;
325
+ this.open(false);
280
326
  }
281
327
  }
282
328
 
329
+ _handleBlur = () => {
330
+ this.isFocused = false;
331
+ this.close();
332
+ }
283
333
 
334
+ _getAttributeOptions() {
335
+ const attributeOptions = {};
336
+ const tooltipTextOption = this.el.getAttribute('data-tooltip');
337
+ const positionOption = this.el.getAttribute('data-position');
338
+ if (tooltipTextOption) {
339
+ (attributeOptions as any).text = tooltipTextOption;
340
+ }
341
+ if (positionOption) {
342
+ (attributeOptions as any).position = positionOption;
343
+ }
344
+ return attributeOptions;
345
+ }
346
+ }