@materializecss/materialize 2.0.1-alpha → 2.0.2-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.
- package/Gruntfile.js +5 -2
- package/dist/css/materialize.css +90 -86
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.js +2797 -2705
- package/dist/js/materialize.min.js +2 -8967
- package/dist/js/materialize.min.js.map +1 -1
- package/package.json +1 -1
- package/sass/components/_collapsible.scss +0 -41
- package/sass/components/_global.scss +3 -2
- package/sass/components/_icons-material-design.scss +2 -1
- package/sass/components/_navbar.scss +6 -3
- package/sass/components/_sidenav.scss +66 -37
- package/sass/components/_theme_variables.scss +2 -2
- package/sass/components/_typography.scss +2 -2
- package/sass/components/forms/_input-fields.scss +4 -10
- package/sass/materialize.scss +0 -4
- package/src/autocomplete.ts +188 -94
- package/src/buttons.ts +225 -260
- package/src/cards.ts +5 -6
- package/src/carousel.ts +611 -542
- package/src/characterCounter.ts +50 -21
- package/src/chips.ts +152 -63
- package/src/collapsible.ts +97 -32
- package/src/component.ts +99 -10
- package/src/datepicker.ts +905 -726
- package/src/dropdown.ts +576 -484
- package/src/edges.ts +4 -4
- package/src/forms.ts +17 -14
- package/src/global.ts +55 -324
- package/src/materialbox.ts +354 -298
- package/src/modal.ts +296 -211
- package/src/parallax.ts +129 -105
- package/src/pushpin.ts +148 -103
- package/src/range.ts +166 -150
- package/src/scrollspy.ts +214 -174
- package/src/select.ts +434 -398
- package/src/sidenav.ts +447 -381
- package/src/slider.ts +421 -362
- package/src/tabs.ts +276 -222
- package/src/tapTarget.ts +246 -213
- package/src/timepicker.ts +738 -614
- package/src/toasts.ts +254 -230
- package/src/tooltip.ts +315 -252
- package/src/utils.ts +271 -0
- 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
103
|
+
static get defaults(): TooltipOptions {
|
|
104
|
+
return _defaults;
|
|
105
|
+
}
|
|
47
106
|
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
128
|
+
static getInstance(el: HTMLElement): Tooltip {
|
|
129
|
+
return (el as any).M_Tooltip;
|
|
130
|
+
}
|
|
56
131
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
132
|
+
destroy() {
|
|
133
|
+
this.tooltipEl.remove();
|
|
134
|
+
this._removeEventHandlers();
|
|
135
|
+
(this.el as any).M_Tooltip = undefined;
|
|
136
|
+
}
|
|
62
137
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
138
|
+
_appendTooltipEl() {
|
|
139
|
+
this.tooltipEl = document.createElement('div');
|
|
140
|
+
this.tooltipEl.classList.add('material-tooltip');
|
|
66
141
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
153
|
+
_updateTooltipContent() {
|
|
154
|
+
this._setTooltipContent(this.tooltipEl.querySelector('.tooltip-content'));
|
|
155
|
+
}
|
|
93
156
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.isFocused
|
|
126
|
-
this.
|
|
127
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this.
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
+
}
|