react-transition-group#Transition JavaScript Examples

The following examples show how to use react-transition-group#Transition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Fade.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
defaultProps = _objectSpread2({}, Transition.defaultProps, {
  tag: 'div',
  baseClass: 'fade',
  baseClassActive: 'show',
  timeout: TransitionTimeouts.Fade,
  appear: true,
  enter: true,
  exit: true,
  in: true
})
Example #2
Source File: AnimatedSection.jsx    From one-wallet with Apache License 2.0 6 votes vote down vote up
AnimatedSection2 = ({ show = true, SectionEl = DefaultEmptySection, children, style, ...params }) => {
  return (
    <Transition in={show} timeout={300}>
      {state => (
        <SectionEl
          style={{
            maxWidth: '640px',
            ...defaultStyle,
            ...transitionStyles[state],
            ...style
          }}
          {...params}
        >
          {children}
        </SectionEl>
      )}
    </Transition>
  )
}
Example #3
Source File: AnimatedSection.jsx    From one-wallet with Apache License 2.0 6 votes vote down vote up
AnimatedSection = ({ show = true, wide, children, style, onClose, ...params }) => {
  const { isMobile } = useWindowDimensions()
  return (
    <Transition in={show} timeout={300}>
      {state => (
        <Section
          data-show={show}
          headStyle={{
            padding: isMobile && 0,
            marginTop: isMobile ? -16 : 0,
          }}
          bodyStyle={{
            padding: isMobile ? 0 : 24,
            paddingTop: isMobile ? 12 : 24,
          }}
          tabProps={{ renderTabBar }}
          style={{
            padding: isMobile ? 16 : 32,
            maxWidth: wide ? 720 : 640,
            minHeight: wide ? 320 : undefined,
            ...defaultStyle,
            ...transitionStyles[state],
            ...style
          }}
          {...onClose && { extra: [<Button key='close' type='text' icon={<CloseOutlined />} onClick={onClose} />] }}
          {...params}
        >
          {children}
        </Section>
      )}
    </Transition>
  )
}
Example #4
Source File: Fade.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
defaultProps = {
  ...Transition.defaultProps,
  tag: 'div',
  baseClass: 'fade',
  baseClassActive: 'show',
  timeout: TransitionTimeouts.Fade,
  appear: true,
  enter: true,
  exit: true,
  in: true,
}
Example #5
Source File: Fade.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
propTypes = {
  ...Transition.propTypes,
  children: PropTypes.oneOfType([
    PropTypes.arrayOf(PropTypes.node),
    PropTypes.node
  ]),
  tag: tagPropType,
  baseClass: PropTypes.string,
  baseClassActive: PropTypes.string,
  className: PropTypes.string,
  cssModule: PropTypes.object,
  innerRef: PropTypes.oneOfType([
    PropTypes.object,
    PropTypes.string,
    PropTypes.func,
  ]),
}
Example #6
Source File: Fade.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
function Fade(props) {
  const {
    tag: Tag,
    baseClass,
    baseClassActive,
    className,
    cssModule,
    children,
    innerRef,
    ...otherProps
  } = props;

  const transitionProps = pick(otherProps, TransitionPropTypeKeys);
  const childProps = omit(otherProps, TransitionPropTypeKeys);

  return (
    <Transition {...transitionProps}>
      {(status) => {
        const isActive = status === 'entered';
        const classes = mapToCssModules(classNames(
          className,
          baseClass,
          isActive && baseClassActive
        ), cssModule);
        return (
          <Tag className={classes} {...childProps} ref={innerRef}>
            {children}
          </Tag>
        );
      }}
    </Transition>
  );
}
Example #7
Source File: Collapse.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
defaultProps = {
  ...Transition.defaultProps,
  isOpen: false,
  appear: false,
  enter: true,
  exit: true,
  tag: 'div',
  timeout: TransitionTimeouts.Collapse,
}
Example #8
Source File: Collapse.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
propTypes = {
  ...Transition.propTypes,
  isOpen: PropTypes.bool,
  children: PropTypes.oneOfType([
    PropTypes.arrayOf(PropTypes.node),
    PropTypes.node
  ]),
  tag: tagPropType,
  className: PropTypes.node,
  navbar: PropTypes.bool,
  cssModule: PropTypes.object,
  innerRef: PropTypes.oneOfType([
    PropTypes.func,
    PropTypes.string,
    PropTypes.object
  ]),
}
Example #9
Source File: CarouselItem.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
CarouselItem.propTypes = {
  ...Transition.propTypes,
  tag: tagPropType,
  in: PropTypes.bool,
  cssModule: PropTypes.object,
  children: PropTypes.node,
  slide: PropTypes.bool,
  className: PropTypes.string,
};
Example #10
Source File: Fade.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
propTypes = _objectSpread2({}, Transition.propTypes, {
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
  tag: tagPropType,
  baseClass: PropTypes.string,
  baseClassActive: PropTypes.string,
  className: PropTypes.string,
  cssModule: PropTypes.object,
  innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func])
})
Example #11
Source File: Fade.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
function Fade(props) {
  var Tag = props.tag,
      baseClass = props.baseClass,
      baseClassActive = props.baseClassActive,
      className = props.className,
      cssModule = props.cssModule,
      children = props.children,
      innerRef = props.innerRef,
      otherProps = _objectWithoutPropertiesLoose(props, ["tag", "baseClass", "baseClassActive", "className", "cssModule", "children", "innerRef"]);

  var transitionProps = pick(otherProps, TransitionPropTypeKeys);
  var childProps = omit(otherProps, TransitionPropTypeKeys);
  return React.createElement(Transition, transitionProps, function (status) {
    var isActive = status === 'entered';
    var classes = mapToCssModules(classNames(className, baseClass, isActive && baseClassActive), cssModule);
    return React.createElement(Tag, _extends({
      className: classes
    }, childProps, {
      ref: innerRef
    }), children);
  });
}
Example #12
Source File: Collapse.js    From Rick-and-Morty-React-App-Card-API with MIT License 6 votes vote down vote up
propTypes = _objectSpread2({}, Transition.propTypes, {
  isOpen: PropTypes.bool,
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
  tag: tagPropType,
  className: PropTypes.node,
  navbar: PropTypes.bool,
  cssModule: PropTypes.object,
  innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.object])
})
Example #13
Source File: dimmer-with-message.js    From orangutan-monorepo with MIT License 6 votes vote down vote up
export default function DimmerWithMessage(props) {
  return (
    <Transition unmountOnExit in={props.show} timeout={transitionDuration}>
      {state => (
        <Container state={state}>
          <Dimmer />
          <Text shining={props.shining}>{props.message}</Text>
        </Container>
      )}
    </Transition>
  )
}
Example #14
Source File: FadeTransition.js    From juggernaut-desktop with MIT License 6 votes vote down vote up
FadeTransition = ({ in: inProp }) => (
  <Transition in={inProp} timeout={duration}>
    {state => (
      <div
        style={{
          ...defaultStyle,
          ...transitionStyles[state]
        }}
      />
    )}
  </Transition>
)
Example #15
Source File: TransitionWrapper.jsx    From ui-neumorphism with MIT License 6 votes vote down vote up
render() {
    const { children, onUpdate, ...otherProps } = this.props
    return (
      <Transition
        onExit={this.handleExit}
        onEnter={this.handleEnter}
        onExited={this.handleExited}
        onEntered={this.handleEntered}
        onExiting={this.handleExiting}
        onEntering={this.handleEntering}
        {...otherProps}
      >
        {children}
      </Transition>
    )
  }
Example #16
Source File: LoadingScreen.js    From covidcg with MIT License 5 votes vote down vote up
LoadingScreen = observer(() => {
  const [progressText, setProgressText] = useState('');

  useEffect(() => {
    if (asyncDataStoreInstance.status === ASYNC_STATES.FAILED) {
      setProgressText(
        <span>
          Error fetching data. Please refresh this page. If this error persists,
          please contact us at{' '}
          <ExternalLink href="mailto:[email protected]">
            [email protected]
          </ExternalLink>
        </span>
      );
    } else if (asyncDataStoreInstance.status !== ASYNC_STATES.SUCCEEDED) {
      setProgressText(<span>Initializing...</span>);
    }
  }, [asyncDataStoreInstance.status]);

  useEffect(() => {
    // Display message to try a refresh if this is taking too long
    // Timer set at 5 seconds
    setTimeout(() => {
      if (asyncDataStoreInstance.status === ASYNC_STATES.STARTED) {
        setProgressText(
          <span>
            Initializing...
            <br />
            If this is taking too long, try refreshing the page.
            <br />
            If the error persists, please contact us at{' '}
            <ExternalLink href="mailto:[email protected]">
              [email protected]
            </ExternalLink>
          </span>
        );
      }
    }, 10000);
  }, []);

  return (
    <LoadingScreenContainer>
      <Transition in appear enter timeout={duration}>
        {(state) => (
          <LogoContainer
            style={{
              ...defaultStyle,
              ...transitionStyles[state],
            }}
          >
            <img src={CGLogo}></img>
          </LogoContainer>
        )}
      </Transition>
      <Transition in appear enter timeout={300}>
        {(state) => (
          <ProgressContainer
            style={{
              ...loadingDefaultStyles,
              ...loadingTransitionStyles[state],
            }}
          >
            <LoadingSpinner
              visible={asyncDataStoreInstance.status !== ASYNC_STATES.FAILED}
            />
            <ProgressText>{progressText}</ProgressText>
          </ProgressContainer>
        )}
      </Transition>
    </LoadingScreenContainer>
  );
})
Example #17
Source File: Collapse.js    From tonic-ui with MIT License 5 votes vote down vote up
Collapse = forwardRef((
  {
    appear = false, // do not perform the enter transition when it first mounts
    children,
    collapsedHeight = 0,
    easing = defaultEasing,
    in: inProp,
    style,
    timeout = defaultTimeout,
    ...rest
  },
  ref,
) => {
  const nodeRef = useRef(null);
  const combinedRef = useMergeRefs(nodeRef, ref);
  const wrapperRef = useRef(null);

  useEffect(() => {
    const node = nodeRef.current;
    reflow(node); // force reflow to make the transition work when animating appearance
  }, [inProp]);

  return (
    <Transition
      appear={appear}
      in={inProp}
      nodeRef={nodeRef}
      timeout={timeout}
      {...rest}
    >
      {(state, childProps) => {
        const transitionProps = inProp
          ? getEnterTransitionProps({ style, timeout, easing })
          : getExitTransitionProps({ style, timeout, easing });
        const transition = createTransitionStyle(['height', 'opacity'], transitionProps);
        const variantStyle = mapStateToVariantStyle(state, { collapsedHeight });
        const styleProps = {
          ...variantStyle,
          transition,
          visibility: (state === 'exited' && !inProp && !collapsedHeight) ? 'hidden' : undefined,
        };

        if (typeof children === 'function') {
          return children(state, {
            ...childProps,
            ref: combinedRef,
            style: {
              ...styleProps,
              ...style,
            },
          });
        }

        const isAnimationStart = (inProp && (state === 'entering')) ||
          (!inProp && (state === 'entering' || state === 'entered'));
        //const isAnimationEnd = (inProp && (state === 'entered')) ||
        //  (!inProp && (state === 'exited'));

        if (isAnimationStart) {
          const wrapper = wrapperRef.current;
          const contentHeight = wrapper?.offsetHeight;
          styleProps.height = contentHeight;
        }

        return (
          <Box
            ref={combinedRef}
            {...childProps}
            {...styleProps}
            style={style}
          >
            <Wrapper ref={wrapperRef}>
              {children}
            </Wrapper>
          </Box>
        );
      }}
    </Transition>
  );
})
Example #18
Source File: Fade.js    From tonic-ui with MIT License 5 votes vote down vote up
Fade = forwardRef((
  {
    appear = false, // do not perform the enter transition when it first mounts
    children,
    easing = defaultEasing,
    in: inProp,
    style,
    timeout = defaultTimeout,
    ...rest
  },
  ref,
) => {
  const nodeRef = useRef(null);
  const combinedRef = useMergeRefs(nodeRef, ref);

  useEffect(() => {
    if (inProp) {
      const node = nodeRef.current;
      reflow(node); // force reflow to make the transition work when animating appearance
    }
  }, [inProp]);

  return (
    <Transition
      appear={appear}
      in={inProp}
      nodeRef={nodeRef}
      timeout={timeout}
      {...rest}
    >
      {(state, childProps) => {
        const transitionProps = inProp
          ? getEnterTransitionProps({ style, timeout, easing })
          : getExitTransitionProps({ style, timeout, easing });
        const transition = createTransitionStyle('opacity', transitionProps);
        const variantStyle = mapStateToVariantStyle(state, {});
        const styleProps = {
          ...variantStyle,
          transition,
          visibility: (state === 'exited' && !inProp) ? 'hidden' : undefined,
        };

        if (typeof children === 'function') {
          return children(state, {
            ...childProps,
            ref: combinedRef,
            style: {
              ...styleProps,
              ...style,
            },
          });
        }

        return (
          <Box
            ref={combinedRef}
            {...childProps}
            {...styleProps}
            style={style}
          >
            {children}
          </Box>
        );
      }}
    </Transition>
  );
})
Example #19
Source File: MenuToggleIcon.js    From tonic-ui with MIT License 5 votes vote down vote up
MenuToggleIcon = forwardRef((
  {
    appear = false, // do not perform the enter transition when it first mounts
    children,
    disabled,
    easing = defaultEasing,
    style,
    timeout = defaultTimeout,
    ...rest
  },
  ref,
) => {
  const menuContext = useMenu(); // context might be an undefined value
  const {
    isOpen,
    direction,
  } = { ...menuContext };
  const menuIndicatorStyleProps = useMenuToggleIconStyle();
  const nodeRef = useRef(null);
  const combinedRef = useMergeRefs(nodeRef, ref);

  useEffect(() => {
    if (isOpen) {
      const node = nodeRef.current;
      reflow(node); // force reflow to make the transition work when animating appearance
    }
  }, [isOpen]);

  return (
    <Transition
      appear={appear}
      in={isOpen}
      nodeRef={nodeRef}
      timeout={timeout}
      {...rest}
    >
      {(state, childProps) => {
        const transitionProps = isOpen
          ? getEnterTransitionProps({ style, timeout, easing })
          : getExitTransitionProps({ style, timeout, easing });
        const transition = createTransitionStyle('transform', transitionProps);
        const variantStyle = mapStateToVariantStyle(state, { direction });
        const styleProps = {
          ...menuIndicatorStyleProps,
          ...variantStyle,
          'aria-disabled': disabled,
          transition,
        };

        if (typeof children === 'function') {
          return children(state, {
            ...childProps,
            ref: combinedRef,
            style: {
              ...styleProps,
              ...style,
            },
          });
        }

        const iconName = mapDirectionToIconName(direction);

        return (
          <Box
            ref={combinedRef}
            {...styleProps}
            {...childProps}
            style={style}
          >
            {children ?? <Icon width="4x" icon={iconName} />}
          </Box>
        );
      }}
    </Transition>
  );
})
Example #20
Source File: AccordionToggleIcon.js    From tonic-ui with MIT License 5 votes vote down vote up
AccordionToggleIcon = forwardRef((
  {
    appear = false, // do not perform the enter transition when it first mounts
    children,
    disabled: disabledProp,
    easing = defaultEasing,
    style,
    timeout = defaultTimeout,
    ...rest
  },
  ref,
) => {
  const context = useAccordionItem(); // context might be an undefined value
  const iconStyleProps = useAccordionToggleIconStyle();
  const nodeRef = useRef(null);
  const combinedRef = useMergeRefs(nodeRef, ref);
  const disabled = ensureBoolean(disabledProp ?? context?.disabled);
  const isExpanded = ensureBoolean(context?.isExpanded);

  useEffect(() => {
    if (isExpanded) {
      const node = nodeRef.current;
      reflow(node); // force reflow to make the transition work when animating appearance
    }
  }, [isExpanded]);

  return (
    <Transition
      appear={appear}
      in={isExpanded}
      nodeRef={nodeRef}
      timeout={timeout}
      {...rest}
    >
      {(state, childProps) => {
        const transitionProps = isExpanded
          ? getEnterTransitionProps({ style, timeout, easing })
          : getExitTransitionProps({ style, timeout, easing });
        const transition = createTransitionStyle('transform', transitionProps);
        const variantStyle = mapStateToVariantStyle(state, {});
        const styleProps = {
          ...iconStyleProps,
          ...variantStyle,
          'aria-disabled': disabled,
          transition,
        };

        if (typeof children === 'function') {
          return children(state, {
            ...childProps,
            ref: combinedRef,
            style: {
              ...styleProps,
              ...style,
            },
          });
        }

        const iconName = 'chevron-down';

        return (
          <Box
            ref={combinedRef}
            {...styleProps}
            {...childProps}
            style={style}
          >
            {children ?? <Icon width="4x" icon={iconName} />}
          </Box>
        );
      }}
    </Transition>
  );
})
Example #21
Source File: Scale.js    From tonic-ui with MIT License 5 votes vote down vote up
Scale = forwardRef((
  {
    appear = false, // do not perform the enter transition when it first mounts
    children,
    easing = defaultEasing,
    in: inProp,
    initialScale = defaultInitialScale,
    style,
    timeout = defaultTimeout,
    ...rest
  },
  ref,
) => {
  const nodeRef = useRef(null);
  const combinedRef = useMergeRefs(nodeRef, ref);

  useEffect(() => {
    if (inProp) {
      const node = nodeRef.current;
      reflow(node); // force reflow to make the transition work when animating appearance
    }
  }, [inProp]);

  return (
    <Transition
      appear={appear}
      in={inProp}
      nodeRef={nodeRef}
      timeout={timeout}
      {...rest}
    >
      {(state, childProps) => {
        const transitionProps = inProp
          ? getEnterTransitionProps({ style, timeout, easing })
          : getExitTransitionProps({ style, timeout, easing });
        const transition = createTransitionStyle('transform', transitionProps);
        const variantStyle = mapStateToVariantStyle(state, { initialScale });
        const styleProps = {
          ...variantStyle,
          transition,
          visibility: (state === 'exited' && !inProp) ? 'hidden' : undefined,
        };

        if (typeof children === 'function') {
          return children(state, {
            ...childProps,
            ref: combinedRef,
            style: {
              ...styleProps,
              ...style,
            },
          });
        }

        return (
          <Box
            ref={combinedRef}
            {...childProps}
            {...styleProps}
            style={style}
          >
            {children}
          </Box>
        );
      }}
    </Transition>
  );
})
Example #22
Source File: Slide.js    From tonic-ui with MIT License 5 votes vote down vote up
Slide = forwardRef((
  {
    appear = false, // do not perform the enter transition when it first mounts
    children,
    direction = DIRECTION_DOWN,
    easing = defaultEasing,
    in: inProp,
    style,
    timeout = defaultTimeout,
    ...rest
  },
  ref,
) => {
  const nodeRef = useRef(null);
  const combinedRef = useMergeRefs(nodeRef, ref);

  useEffect(() => {
    if (inProp) {
      const node = nodeRef.current;
      reflow(node); // force reflow to make the transition work when animating appearance
    }
  }, [inProp]);

  return (
    <Transition
      appear={appear}
      in={inProp}
      nodeRef={nodeRef}
      timeout={timeout}
      {...rest}
    >
      {(state, childProps) => {
        const transitionProps = inProp
          ? getEnterTransitionProps({ style, timeout, easing })
          : getExitTransitionProps({ style, timeout, easing });
        const transition = createTransitionStyle('transform', transitionProps);
        const variantStyle = mapStateToVariantStyle(state, { direction });
        const styleProps = {
          ...variantStyle,
          transition,
          visibility: (state === 'exited' && !inProp) ? 'hidden' : undefined,
        };

        if (typeof children === 'function') {
          return children(state, {
            ...childProps,
            ref: combinedRef,
            style: {
              ...styleProps,
              ...style,
            },
          });
        }

        return (
          <Box
            ref={combinedRef}
            {...childProps}
            {...styleProps}
            style={style}
          >
            {children}
          </Box>
        );
      }}
    </Transition>
  );
})
Example #23
Source File: Zoom.js    From tonic-ui with MIT License 5 votes vote down vote up
Zoom = forwardRef((
  {
    appear = false, // do not perform the enter transition when it first mounts
    children,
    easing = defaultEasing,
    in: inProp,
    style,
    timeout = defaultTimeout,
    ...rest
  },
  ref,
) => {
  const nodeRef = useRef(null);
  const combinedRef = useMergeRefs(nodeRef, ref);

  useEffect(() => {
    if (inProp) {
      const node = nodeRef.current;
      reflow(node); // force reflow to make the transition work when animating appearance
    }
  }, [inProp]);

  return (
    <Transition
      appear={appear}
      in={inProp}
      nodeRef={nodeRef}
      timeout={timeout}
      {...rest}
    >
      {(state, childProps) => {
        const transitionProps = inProp
          ? getEnterTransitionProps({ style, timeout, easing })
          : getExitTransitionProps({ style, timeout, easing });
        const transition = createTransitionStyle('transform', transitionProps);
        const variantStyle = mapStateToVariantStyle(state, {});
        const styleProps = {
          ...variantStyle,
          transition,
          visibility: (state === 'exited' && !inProp) ? 'hidden' : undefined,
        };

        if (typeof children === 'function') {
          return children(state, {
            ...childProps,
            ref: combinedRef,
            style: {
              ...styleProps,
              ...style,
            },
          });
        }

        return (
          <Box
            ref={combinedRef}
            {...childProps}
            {...styleProps}
            style={style}
          >
            {children}
          </Box>
        );
      }}
    </Transition>
  );
})
Example #24
Source File: Collapse.js    From Rick-and-Morty-React-App-Card-API with MIT License 5 votes vote down vote up
render() {
    const {
      tag: Tag,
      isOpen,
      className,
      navbar,
      cssModule,
      children,
      innerRef,
      ...otherProps
    } = this.props;

    const { height } = this.state;

    const transitionProps = pick(otherProps, TransitionPropTypeKeys);
    const childProps = omit(otherProps, TransitionPropTypeKeys);
    return (
      <Transition
        {...transitionProps}
        in={isOpen}
        onEntering={this.onEntering}
        onEntered={this.onEntered}
        onExit={this.onExit}
        onExiting={this.onExiting}
        onExited={this.onExited}
      >
        {(status) => {
          let collapseClass = getTransitionClass(status);
          const classes = mapToCssModules(classNames(
            className,
            collapseClass,
            navbar && 'navbar-collapse'
          ), cssModule);
          const style = height === null ? null : { height };
          return (
            <Tag
              {...childProps}
              style={{ ...childProps.style, ...style }}
              className={classes}
              ref={this.props.innerRef}
            >
              {children}
            </Tag>
          );
        }}
      </Transition>
    );
  }
Example #25
Source File: CarouselItem.js    From Rick-and-Morty-React-App-Card-API with MIT License 5 votes vote down vote up
CarouselItem.defaultProps = {
  ...Transition.defaultProps,
  tag: 'div',
  timeout: TransitionTimeouts.Carousel,
  slide: true,
};
Example #26
Source File: CarouselItem.js    From Rick-and-Morty-React-App-Card-API with MIT License 5 votes vote down vote up
render() {
    const { in: isIn, children, cssModule, slide, tag: Tag, className, ...transitionProps } = this.props;

    return (
      <Transition
        {...transitionProps}
        enter={slide}
        exit={slide}
        in={isIn}
        onEnter={this.onEnter}
        onEntering={this.onEntering}
        onExit={this.onExit}
        onExiting={this.onExiting}
        onExited={this.onExited}
      >
        {(status) => {
          const { direction } = this.context;
          const isActive = (status === TransitionStatuses.ENTERED) || (status === TransitionStatuses.EXITING);
          const directionClassName = (status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING) &&
            this.state.startAnimation &&
            (direction === 'right' ? 'carousel-item-left' : 'carousel-item-right');
          const orderClassName = (status === TransitionStatuses.ENTERING) &&
            (direction === 'right' ? 'carousel-item-next' : 'carousel-item-prev');
          const itemClasses = mapToCssModules(classNames(
            className,
            'carousel-item',
            isActive && 'active',
            directionClassName,
            orderClassName,
          ), cssModule);

          return (
            <Tag className={itemClasses}>
              {children}
            </Tag>
          );
        }}
      </Transition>
    );
  }
Example #27
Source File: Collapse.js    From Rick-and-Morty-React-App-Card-API with MIT License 5 votes vote down vote up
defaultProps = _objectSpread2({}, Transition.defaultProps, {
  isOpen: false,
  appear: false,
  enter: true,
  exit: true,
  tag: 'div',
  timeout: TransitionTimeouts.Collapse
})
Example #28
Source File: CarouselItem.js    From Rick-and-Morty-React-App-Card-API with MIT License 5 votes vote down vote up
CarouselItem.defaultProps = _objectSpread2({}, Transition.defaultProps, {
  tag: 'div',
  timeout: TransitionTimeouts.Carousel,
  slide: true
});
Example #29
Source File: CarouselItem.js    From Rick-and-Morty-React-App-Card-API with MIT License 5 votes vote down vote up
CarouselItem.propTypes = _objectSpread2({}, Transition.propTypes, {
  tag: tagPropType,
  in: PropTypes.bool,
  cssModule: PropTypes.object,
  children: PropTypes.node,
  slide: PropTypes.bool,
  className: PropTypes.string
});