Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow style transition: all causes glitchy animation when the arrow changes direction #35

Open
sompylasar opened this issue Dec 8, 2016 · 4 comments
Labels

Comments

@sompylasar
Copy link
Contributor

Why is this transition needed? I've managed to disable it via arrowStyle override, and nothing's broken, the glitch fixed.

@Redmega
Copy link
Collaborator

Redmega commented Aug 7, 2017

@sompylasar Can you recreate on CodeSandbox for testing?

@Redmega Redmega added the bug label Aug 7, 2017
@sompylasar
Copy link
Contributor Author

Wow 8 months ago... I haven't touched that part of the app for months. I'll try to reproduce, but no promises.

@Redmega
Copy link
Collaborator

Redmega commented Aug 7, 2017

Oh, sorry! Didn't see the open date for the issue. I'll try to reproduce after work, no big deal. I'm just trying to understand the use case.

Were you changing the arrow from left to right for example, on the same tooltip, or is it between two tooltips with different arrows?

@sompylasar
Copy link
Contributor Author

sompylasar commented Aug 7, 2017

On the same tooltip. See the repro screen recording (sorry for the low FPS but the glitch is visible):
tooltip-30fps

Here's the code:

  render() {
    const [ Anchor, TooltipContent ] = this.props.children;

    const {
      tooltipWrapStyle,
      tooltipStyle,
      tooltipArrowStyle,
      tooltipPosition,
      tooltipTimeout,
      tooltipForceActive,
    } = this.props;

    const {
      tooltipId,
      isTooltipActive,
    } = this.state;

    const ConnectedAnchor = cloneElement( Anchor, {
      onMouseEnter: this._showTooltip,
      onMouseLeave: this._hideTooltip,
      onTouchTap: this._toggleTooltip,
      id: tooltipId,
    });

    const _tooltipContentStyle = {
      fontWeight: '600',
      fontSize: '13px',
      color: '#fff',
      textAlign: 'left',
    };

    const _tooltipStyle = {
      background: 'rgba(40, 40, 40, 0.9)',  // $rsh-tooltip-background-color
      boxShadow: 'none',
      borderRadius: '4px',
      padding: '8px',
      lineHeight: '16px',
      ..._tooltipContentStyle,
      ...tooltipStyle,
    };

    // NOTE: `react-portal-tooltip` won't let the arrow's width / height / border-radius to be styled.
    const _tooltipArrowStyle = {
      color: 'rgba(40, 40, 40, 0.9)',  // $rsh-tooltip-background-color
      borderColor: null,
      // WORKAROUND(@sompylasar): Disable arrow transition, otherwise the animation looks glitchy when the arrow direction changes.
      //transition: null,   //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      ...tooltipArrowStyle,
    };

    const reactPortalTooltipStyle = {
      style: _tooltipStyle,
      arrowStyle: _tooltipArrowStyle,
    };

    return (
      <div style={ tooltipWrapStyle }>
        { ConnectedAnchor }
        <ReactPortalTooltip
          active={typeof tooltipForceActive === 'boolean'
            ? tooltipForceActive
            : isTooltipActive
          }
          position={tooltipPosition}
          arrow="center"
          style={reactPortalTooltipStyle}
          parent={`#${tooltipId}`}
          tooltipTimeout={typeof tooltipForceActive === 'boolean' ? 0 : tooltipTimeout}
        >
          <div style={_tooltipContentStyle}>
            { TooltipContent }
          </div>
        </ReactPortalTooltip>
      </div>
    );
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants