@@ -89,36 +89,27 @@ export default class TooltipTrigger extends PureComponent {
8989 clearTimeout ( this . _showTimeout ) ;
9090 } ;
9191
92- showTooltip = ( ) => {
92+ showTooltip = ( delay = this . props . delayShow ) => {
9393 this . _clearScheduled ( ) ;
94- this . setState ( { tooltipShown : true } ) ;
95- } ;
9694
97- hideTooltip = ( ) => {
98- this . _clearScheduled ( ) ;
99- this . setState ( { tooltipShown : false } ) ;
100- } ;
101-
102- toggleTooltip = ( ) => {
103- this . _clearScheduled ( ) ;
104- this . setState ( prevState => ( {
105- tooltipShown : ! prevState . tooltipShown
106- } ) ) ;
95+ this . _showTimeout = setTimeout (
96+ ( ) => this . setState ( { tooltipShown : true } ) ,
97+ delay
98+ ) ;
10799 } ;
108100
109- scheduleShow = ( ) => {
101+ hideTooltip = ( delay = this . props . delayHide ) => {
110102 this . _clearScheduled ( ) ;
111- this . _showTimeout = setTimeout ( this . showTooltip , this . props . delayShow ) ;
112- } ;
113103
114- scheduleHide = ( ) => {
115- this . _clearScheduled ( ) ;
116- this . _hideTimeout = setTimeout ( this . hideTooltip , this . props . delayHide ) ;
104+ this . _hideTimeout = setTimeout (
105+ ( ) => this . setState ( { tooltipShown : false } ) ,
106+ delay
107+ ) ;
117108 } ;
118109
119- scheduleToggle = ( ) => {
120- const action = this . state . tooltipShown ? 'scheduleHide ' : 'scheduleShow ' ;
121- this [ action ] ( ) ;
110+ toggleTooltip = delay => {
111+ const action = this . state . tooltipShown ? 'hideTooltip ' : 'showTooltip ' ;
112+ this [ action ] ( delay ) ;
122113 } ;
123114
124115 _contextMenuToggle = event => {
@@ -142,17 +133,17 @@ export default class TooltipTrigger extends PureComponent {
142133
143134 return {
144135 ...props ,
145- onClick : callAll ( isClickTriggered && this . scheduleToggle , props . onClick ) ,
136+ onClick : callAll ( isClickTriggered && this . toggleTooltip , props . onClick ) ,
146137 onContextMenu : callAll (
147138 isRightClickTriggered && this . _contextMenuToggle ,
148139 props . onContextMenu
149140 ) ,
150141 onMouseEnter : callAll (
151- isHoverTriggered && this . scheduleShow ,
142+ isHoverTriggered && this . showTooltip ,
152143 props . onMouseEnter
153144 ) ,
154145 onMouseLeave : callAll (
155- isHoverTriggered && this . scheduleHide ,
146+ isHoverTriggered && this . hideTooltip ( ) ,
156147 props . onMouseLeave
157148 )
158149 } ;
@@ -172,7 +163,13 @@ export default class TooltipTrigger extends PureComponent {
172163 < Manager >
173164 < Reference >
174165 { ( { ref } ) =>
175- children ( { getTriggerProps : this . getTriggerProps , triggerRef : ref } )
166+ children ( {
167+ getTriggerProps : this . getTriggerProps ,
168+ triggerRef : ref ,
169+ showTooltip : this . showTooltip ,
170+ hideTooltip : this . hideTooltip ,
171+ toggleTooltip : this . toggleTooltip
172+ } )
176173 }
177174 </ Reference >
178175 { this . state . tooltipShown &&
@@ -212,7 +209,6 @@ export default class TooltipTrigger extends PureComponent {
212209 innerRef = { ref }
213210 hideTooltip = { this . hideTooltip }
214211 clearScheduled = { this . _clearScheduled }
215- scheduleHide = { this . scheduleHide }
216212 />
217213 ) }
218214 </ TooltipContext . Consumer >
0 commit comments