Skip to content

Commit

Permalink
new: tooltip modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
parasharrajat committed Mar 25, 2021
1 parent 15d89dc commit 09a5266
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Tooltip/TooltipPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ const propTypes = {
// Any additional amount to manually adjust the vertical position of the tooltip.
// A positive value shifts the tooltip down, and a negative value shifts it up.
shiftVertical: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),

// Delay before the tooltip is visible
showDelay: PropTypes.number,

// Delay before the tooltip is hidden
hideDelay: PropTypes.number,
};

const defaultProps = {
shiftHorizontal: 0,
shiftVertical: 0,
showDelay: 500,
hideDelay: 0,
};

export {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class Tooltip extends PureComponent {
* Display the tooltip in an animation.
*/
showTooltip() {
this.animation.stopAnimation();
this.shouldStartShowAnimation = true;

// We have to dynamically calculate the position here as tooltip could have been rendered on some elments
Expand All @@ -148,6 +149,7 @@ class Tooltip extends PureComponent {
Animated.timing(this.animation, {
toValue: 1,
duration: 140,
delay: this.props.showDelay,
}).start();
}
});
Expand All @@ -157,10 +159,12 @@ class Tooltip extends PureComponent {
* Hide the tooltip in an animation.
*/
hideTooltip() {
this.animation.stopAnimation();
this.shouldStartShowAnimation = false;
Animated.timing(this.animation, {
toValue: 0,
duration: 140,
delay: this.props.hideDelay,
}).start();
}

Expand Down

0 comments on commit 09a5266

Please sign in to comment.