@@ -4,6 +4,8 @@ import { Utils } from "./utils";
4
4
import { Bounding } from "./bounding" ;
5
5
import { Component , BaseOptions , InitElements , MElement } from "./component" ;
6
6
7
+ export type TooltipPosition = 'top' | 'right' | 'bottom' | 'left' ;
8
+
7
9
export interface TooltipOptions extends BaseOptions {
8
10
/**
9
11
* Delay time before tooltip disappears.
@@ -45,7 +47,7 @@ export interface TooltipOptions extends BaseOptions {
45
47
* Set the direction of the tooltip.
46
48
* @default 'bottom'
47
49
*/
48
- position : 'top' | 'right' | 'bottom' | 'left' ;
50
+ position : TooltipPosition ;
49
51
/**
50
52
* Amount in px that the tooltip moves during its transition.
51
53
* @default 10
@@ -60,7 +62,7 @@ const _defaults: TooltipOptions = {
60
62
margin : 5 ,
61
63
inDuration : 250 ,
62
64
outDuration : 200 ,
63
- position : 'bottom' ,
65
+ position : 'bottom' as TooltipPosition ,
64
66
transitionMovement : 10 ,
65
67
opacity : 1
66
68
} ;
@@ -331,15 +333,15 @@ export class Tooltip extends Component<TooltipOptions> {
331
333
this . close ( ) ;
332
334
}
333
335
334
- _getAttributeOptions ( ) {
335
- const attributeOptions = { } ;
336
+ _getAttributeOptions ( ) : Partial < TooltipOptions > {
337
+ let attributeOptions : Partial < TooltipOptions > = { } ;
336
338
const tooltipTextOption = this . el . getAttribute ( 'data-tooltip' ) ;
337
339
const positionOption = this . el . getAttribute ( 'data-position' ) ;
338
340
if ( tooltipTextOption ) {
339
- ( attributeOptions as any ) . text = tooltipTextOption ;
341
+ attributeOptions . text = tooltipTextOption ;
340
342
}
341
343
if ( positionOption ) {
342
- ( attributeOptions as any ) . position = positionOption ;
344
+ attributeOptions . position = positionOption as TooltipPosition ;
343
345
}
344
346
return attributeOptions ;
345
347
}
0 commit comments