How to use react-motion - 10 common examples

To help you get started, we’ve selected a few react-motion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpusCapita / react-dates / src / client / components / DatePicker / DatePicker.react.js View on Github external
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import './DatePicker.less';
import DayPicker from '../DayPicker';
import { spring, presets, Motion } from 'react-motion';
import isEqual from 'lodash/isEqual';
import { splitProps, zeroTime } from '../utils';

let springPreset = presets.gentle;
let easeOutCubic = (t) => (--t) * t * t + 1; // eslint-disable-line no-param-reassign

let propTypes = {
  className: PropTypes.string,
  disabled: PropTypes.bool,
  locale: PropTypes.string,
  modifiers: PropTypes.object,
  onChange: PropTypes.func,
  showToLeft: PropTypes.bool,
  showToTop: PropTypes.bool,
  tabIndex: PropTypes.number,
  value: PropTypes.object
};

let defaultProps = {
  className: '',
github OpusCapita / react-dates / src / client / components / DateRangeInput / DateRangeInput.react.js View on Github external
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import './DateRangeInput.less';
import DayPicker from '../DayPicker';
import InputAddonButton from '../InputAddonButton';
import DateVariants from '../DateVariants';
import DateInputField from '../DateInputField';
import isEqual from 'lodash/isEqual';
import dayjs from '../../dayjs';
import { spring, presets, Motion } from 'react-motion';
import getMessage from '../translations';
import { splitProps, zeroTime } from '../utils';

let springPreset = presets.gentle;
let easeOutCubic = (t) => (--t) * t * t + 1; // eslint-disable-line no-param-reassign

let initialState = {
  enteredTo: null,
  showPicker: false,
  showVariants: false,
  error: false,
  focused: false
};

function isSelectingFirstDay(from, to, day) {
  let firstDayIsNotSelected = !from;
  let selectedDayIsBeforeFirstDay = day < from;
  let rangeIsSelected = from && to;
  return firstDayIsNotSelected || selectedDayIsBeforeFirstDay || rangeIsSelected;
}
github hanford / react-drag-drawer / src / index.js View on Github external
} = this.props;

    const open = this.state.open && this.props.open;

    // If drawer isn't open or in the process of opening/closing, then remove it from the DOM
    // also, if we're not client side we need to return early because createPortal is only
    // a clientside method
    if ((!this.state.open && !this.props.open) || !isClientSide()) {
      return null;
    }

    const { touching } = this.state;

    const animationSpring = touching
      ? { damping: 20, stiffness: 300 }
      : presets.stiff;

    const hiddenPosition = this.getElementSize();

    const position = this.getPosition(hiddenPosition);

    // Style object for the container element
    let containerStyle = {
      backgroundColor: `rgba(55, 56, 56, ${open ? containerOpacity : 0})`
    };

    // If direction is right, we set the overflowX property to 'hidden' to hide the x scrollbar during
    // the sliding animation
    if (isDirectionRight(direction)) {
      containerStyle = {
        ...containerStyle,
        overflowX: "hidden"
github xtabbas / react-portal-example / src / Modal.js View on Github external
render() {
    const { show } = this.props;

    return ReactDOM.createPortal(
      <div>
        {show ? (
          
            {things =&gt; (
              <div tabindex="{0}" role="button"> { this.node = node; }} style={{ opacity: things.x }} className="modal-backdrop" /&gt;
            )}
          
        ) : null}

        
          { stuff =&gt; (
            </div></div>
github MacKentoch / react-bootstrap-webpack-starter / src / front / components / backToTop / BackToTop.js View on Github external
render() {
    const { showBackButton } = this.state;
    return (
      
        {({ x }) =&gt; (
          
        )}
      
    );
  }
  // #endregion
github MCS-Lite / mcs-lite / packages / mcs-lite-ui / src / LandingHeader / NavItemBurger.js View on Github external
return (
      
        {children &amp;&amp; {children}}
        
          {isShow ?  : }
        

        {/* Portal */}
        {isShow &amp;&amp; (
          
            
              
                {items.map(e =&gt; )}
              
            
          
        )}
      
    );
  }
}
github mendersoftware / gui / node_modules / react-collapse / lib / Collapse.js View on Github external
if (!isOpened &amp;&amp; height &gt; -1) {
          if (!keepCollapsedContent) {
            return null;
          }

          return _react2.default.createElement(
            'div',
            _extends({ style: _extends({ height: 0, overflow: 'hidden' }, style) }, props),
            content
          );
        }

        //  to prevent loosing input after causing this component to rerender
        return _react2.default.createElement(
          _reactMotion.Motion,
          {
            defaultStyle: { height: Math.max(0, height) },
            style: { height: Math.max(0, height) },
            onRest: onRest },
          function () {
            return _react2.default.createElement(
              'div',
              _extends({ style: _extends({}, newStyle, style) }, props),
              content
            );
          }
        );
      }

      return _react2.default.createElement(
        _reactMotion.Motion,
github hew / react-scroll-horizontal / dist / react-scroll-horizontal.js View on Github external
value: function render() {
      var _this4 = this;

      var _props = this.props,
          config = _props.config,
          style = _props.style;
      var width = style.width,
          height = style.height;

      var springConfig = config ? config : _reactMotion.presets.noWobble;

      // Styles
      var styles = _extends({
        height: height ? height : '100%',
        width: width ? width : '100%',
        overflow: 'hidden',
        position: 'relative'
      }, styles);

      return _react2.default.createElement(
        'div',
        {
          onWheel: this.onScrollStart,
          ref: function ref(r) {
            _this4.hScrollParent = r;
          },
github hayeah / react-motion-TransitionSpring-demo / build / app.js View on Github external

"use strict";

var _extends = Object.assign || function (target) { for (var i = 1; i &lt; arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

function _interopRequireDefault(obj) { return obj &amp;&amp; obj.__esModule ? obj : { "default": obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _reactMotion = require("react-motion");

var reorderKeys = _reactMotion.utils.reorderKeys;

var update = _react2["default"].addons;

var Demo = _react2["default"].createClass({
  displayName: "Demo",

  getInitialState: function getInitialState() {
    return {
      // Apparently Object.keys return keys in insertion order (except for 1,2,3).
      letters: {
        "#A": true,
        "#N": true,
        "#T": true
      }
    };
  },
github FormidableLabs / radium-constraints / test / client / spec / components / autodom.spec.jsx View on Github external
animatorProps: (layout) => ({
        style: {
          width: spring(layout.width, presets.wobbly),
          height: spring(layout.height, presets.wobbly),
          top: spring(layout.top, presets.wobbly),
          right: spring(layout.right, presets.wobbly),
          bottom: spring(layout.bottom, presets.wobbly),
          left: spring(layout.left, presets.wobbly)
        }
      })
    });