Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

2821 строка
100 KiB

  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("react"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["react"], factory);
  6. else if(typeof exports === 'object')
  7. exports["ReactMotion"] = factory(require("react"));
  8. else
  9. root["ReactMotion"] = factory(root["React"]);
  10. })(this, function(__WEBPACK_EXTERNAL_MODULE_10__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId])
  20. /******/ return installedModules[moduleId].exports;
  21. /******/
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ exports: {},
  25. /******/ id: moduleId,
  26. /******/ loaded: false
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.loaded = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // __webpack_public_path__
  47. /******/ __webpack_require__.p = "build/";
  48. /******/
  49. /******/ // Load entry module and return exports
  50. /******/ return __webpack_require__(0);
  51. /******/ })
  52. /************************************************************************/
  53. /******/ ([
  54. /* 0 */
  55. /***/ (function(module, exports, __webpack_require__) {
  56. 'use strict';
  57. exports.__esModule = true;
  58. function _interopRequire(obj) { return obj && obj.__esModule ? obj['default'] : obj; }
  59. var _Motion = __webpack_require__(1);
  60. exports.Motion = _interopRequire(_Motion);
  61. var _StaggeredMotion = __webpack_require__(20);
  62. exports.StaggeredMotion = _interopRequire(_StaggeredMotion);
  63. var _TransitionMotion = __webpack_require__(21);
  64. exports.TransitionMotion = _interopRequire(_TransitionMotion);
  65. var _spring = __webpack_require__(23);
  66. exports.spring = _interopRequire(_spring);
  67. var _presets = __webpack_require__(24);
  68. exports.presets = _interopRequire(_presets);
  69. var _stripStyle = __webpack_require__(3);
  70. exports.stripStyle = _interopRequire(_stripStyle);
  71. // deprecated, dummy warning function
  72. var _reorderKeys = __webpack_require__(25);
  73. exports.reorderKeys = _interopRequire(_reorderKeys);
  74. /***/ }),
  75. /* 1 */
  76. /***/ (function(module, exports, __webpack_require__) {
  77. 'use strict';
  78. exports.__esModule = true;
  79. var _extends = Object.assign || function (target) { for (var i = 1; i < 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; };
  80. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  81. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  82. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  83. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  84. var _mapToZero = __webpack_require__(2);
  85. var _mapToZero2 = _interopRequireDefault(_mapToZero);
  86. var _stripStyle = __webpack_require__(3);
  87. var _stripStyle2 = _interopRequireDefault(_stripStyle);
  88. var _stepper3 = __webpack_require__(4);
  89. var _stepper4 = _interopRequireDefault(_stepper3);
  90. var _performanceNow = __webpack_require__(5);
  91. var _performanceNow2 = _interopRequireDefault(_performanceNow);
  92. var _raf = __webpack_require__(7);
  93. var _raf2 = _interopRequireDefault(_raf);
  94. var _shouldStopAnimation = __webpack_require__(9);
  95. var _shouldStopAnimation2 = _interopRequireDefault(_shouldStopAnimation);
  96. var _react = __webpack_require__(10);
  97. var _react2 = _interopRequireDefault(_react);
  98. var _propTypes = __webpack_require__(11);
  99. var _propTypes2 = _interopRequireDefault(_propTypes);
  100. var msPerFrame = 1000 / 60;
  101. var Motion = (function (_React$Component) {
  102. _inherits(Motion, _React$Component);
  103. _createClass(Motion, null, [{
  104. key: 'propTypes',
  105. value: {
  106. // TOOD: warn against putting a config in here
  107. defaultStyle: _propTypes2['default'].objectOf(_propTypes2['default'].number),
  108. style: _propTypes2['default'].objectOf(_propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].object])).isRequired,
  109. children: _propTypes2['default'].func.isRequired,
  110. onRest: _propTypes2['default'].func
  111. },
  112. enumerable: true
  113. }]);
  114. function Motion(props) {
  115. var _this = this;
  116. _classCallCheck(this, Motion);
  117. _React$Component.call(this, props);
  118. this.wasAnimating = false;
  119. this.animationID = null;
  120. this.prevTime = 0;
  121. this.accumulatedTime = 0;
  122. this.unreadPropStyle = null;
  123. this.clearUnreadPropStyle = function (destStyle) {
  124. var dirty = false;
  125. var _state = _this.state;
  126. var currentStyle = _state.currentStyle;
  127. var currentVelocity = _state.currentVelocity;
  128. var lastIdealStyle = _state.lastIdealStyle;
  129. var lastIdealVelocity = _state.lastIdealVelocity;
  130. for (var key in destStyle) {
  131. if (!Object.prototype.hasOwnProperty.call(destStyle, key)) {
  132. continue;
  133. }
  134. var styleValue = destStyle[key];
  135. if (typeof styleValue === 'number') {
  136. if (!dirty) {
  137. dirty = true;
  138. currentStyle = _extends({}, currentStyle);
  139. currentVelocity = _extends({}, currentVelocity);
  140. lastIdealStyle = _extends({}, lastIdealStyle);
  141. lastIdealVelocity = _extends({}, lastIdealVelocity);
  142. }
  143. currentStyle[key] = styleValue;
  144. currentVelocity[key] = 0;
  145. lastIdealStyle[key] = styleValue;
  146. lastIdealVelocity[key] = 0;
  147. }
  148. }
  149. if (dirty) {
  150. _this.setState({ currentStyle: currentStyle, currentVelocity: currentVelocity, lastIdealStyle: lastIdealStyle, lastIdealVelocity: lastIdealVelocity });
  151. }
  152. };
  153. this.startAnimationIfNecessary = function () {
  154. // TODO: when config is {a: 10} and dest is {a: 10} do we raf once and
  155. // call cb? No, otherwise accidental parent rerender causes cb trigger
  156. _this.animationID = _raf2['default'](function (timestamp) {
  157. // check if we need to animate in the first place
  158. var propsStyle = _this.props.style;
  159. if (_shouldStopAnimation2['default'](_this.state.currentStyle, propsStyle, _this.state.currentVelocity)) {
  160. if (_this.wasAnimating && _this.props.onRest) {
  161. _this.props.onRest();
  162. }
  163. // no need to cancel animationID here; shouldn't have any in flight
  164. _this.animationID = null;
  165. _this.wasAnimating = false;
  166. _this.accumulatedTime = 0;
  167. return;
  168. }
  169. _this.wasAnimating = true;
  170. var currentTime = timestamp || _performanceNow2['default']();
  171. var timeDelta = currentTime - _this.prevTime;
  172. _this.prevTime = currentTime;
  173. _this.accumulatedTime = _this.accumulatedTime + timeDelta;
  174. // more than 10 frames? prolly switched browser tab. Restart
  175. if (_this.accumulatedTime > msPerFrame * 10) {
  176. _this.accumulatedTime = 0;
  177. }
  178. if (_this.accumulatedTime === 0) {
  179. // no need to cancel animationID here; shouldn't have any in flight
  180. _this.animationID = null;
  181. _this.startAnimationIfNecessary();
  182. return;
  183. }
  184. var currentFrameCompletion = (_this.accumulatedTime - Math.floor(_this.accumulatedTime / msPerFrame) * msPerFrame) / msPerFrame;
  185. var framesToCatchUp = Math.floor(_this.accumulatedTime / msPerFrame);
  186. var newLastIdealStyle = {};
  187. var newLastIdealVelocity = {};
  188. var newCurrentStyle = {};
  189. var newCurrentVelocity = {};
  190. for (var key in propsStyle) {
  191. if (!Object.prototype.hasOwnProperty.call(propsStyle, key)) {
  192. continue;
  193. }
  194. var styleValue = propsStyle[key];
  195. if (typeof styleValue === 'number') {
  196. newCurrentStyle[key] = styleValue;
  197. newCurrentVelocity[key] = 0;
  198. newLastIdealStyle[key] = styleValue;
  199. newLastIdealVelocity[key] = 0;
  200. } else {
  201. var newLastIdealStyleValue = _this.state.lastIdealStyle[key];
  202. var newLastIdealVelocityValue = _this.state.lastIdealVelocity[key];
  203. for (var i = 0; i < framesToCatchUp; i++) {
  204. var _stepper = _stepper4['default'](msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.stiffness, styleValue.damping, styleValue.precision);
  205. newLastIdealStyleValue = _stepper[0];
  206. newLastIdealVelocityValue = _stepper[1];
  207. }
  208. var _stepper2 = _stepper4['default'](msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.stiffness, styleValue.damping, styleValue.precision);
  209. var nextIdealX = _stepper2[0];
  210. var nextIdealV = _stepper2[1];
  211. newCurrentStyle[key] = newLastIdealStyleValue + (nextIdealX - newLastIdealStyleValue) * currentFrameCompletion;
  212. newCurrentVelocity[key] = newLastIdealVelocityValue + (nextIdealV - newLastIdealVelocityValue) * currentFrameCompletion;
  213. newLastIdealStyle[key] = newLastIdealStyleValue;
  214. newLastIdealVelocity[key] = newLastIdealVelocityValue;
  215. }
  216. }
  217. _this.animationID = null;
  218. // the amount we're looped over above
  219. _this.accumulatedTime -= framesToCatchUp * msPerFrame;
  220. _this.setState({
  221. currentStyle: newCurrentStyle,
  222. currentVelocity: newCurrentVelocity,
  223. lastIdealStyle: newLastIdealStyle,
  224. lastIdealVelocity: newLastIdealVelocity
  225. });
  226. _this.unreadPropStyle = null;
  227. _this.startAnimationIfNecessary();
  228. });
  229. };
  230. this.state = this.defaultState();
  231. }
  232. Motion.prototype.defaultState = function defaultState() {
  233. var _props = this.props;
  234. var defaultStyle = _props.defaultStyle;
  235. var style = _props.style;
  236. var currentStyle = defaultStyle || _stripStyle2['default'](style);
  237. var currentVelocity = _mapToZero2['default'](currentStyle);
  238. return {
  239. currentStyle: currentStyle,
  240. currentVelocity: currentVelocity,
  241. lastIdealStyle: currentStyle,
  242. lastIdealVelocity: currentVelocity
  243. };
  244. };
  245. // it's possible that currentStyle's value is stale: if props is immediately
  246. // changed from 0 to 400 to spring(0) again, the async currentStyle is still
  247. // at 0 (didn't have time to tick and interpolate even once). If we naively
  248. // compare currentStyle with destVal it'll be 0 === 0 (no animation, stop).
  249. // In reality currentStyle should be 400
  250. Motion.prototype.componentDidMount = function componentDidMount() {
  251. this.prevTime = _performanceNow2['default']();
  252. this.startAnimationIfNecessary();
  253. };
  254. Motion.prototype.componentWillReceiveProps = function componentWillReceiveProps(props) {
  255. if (this.unreadPropStyle != null) {
  256. // previous props haven't had the chance to be set yet; set them here
  257. this.clearUnreadPropStyle(this.unreadPropStyle);
  258. }
  259. this.unreadPropStyle = props.style;
  260. if (this.animationID == null) {
  261. this.prevTime = _performanceNow2['default']();
  262. this.startAnimationIfNecessary();
  263. }
  264. };
  265. Motion.prototype.componentWillUnmount = function componentWillUnmount() {
  266. if (this.animationID != null) {
  267. _raf2['default'].cancel(this.animationID);
  268. this.animationID = null;
  269. }
  270. };
  271. Motion.prototype.render = function render() {
  272. var renderedChildren = this.props.children(this.state.currentStyle);
  273. return renderedChildren && _react2['default'].Children.only(renderedChildren);
  274. };
  275. return Motion;
  276. })(_react2['default'].Component);
  277. exports['default'] = Motion;
  278. module.exports = exports['default'];
  279. // after checking for unreadPropStyle != null, we manually go set the
  280. // non-interpolating values (those that are a number, without a spring
  281. // config)
  282. /***/ }),
  283. /* 2 */
  284. /***/ (function(module, exports) {
  285. // currently used to initiate the velocity style object to 0
  286. 'use strict';
  287. exports.__esModule = true;
  288. exports['default'] = mapToZero;
  289. function mapToZero(obj) {
  290. var ret = {};
  291. for (var key in obj) {
  292. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  293. ret[key] = 0;
  294. }
  295. }
  296. return ret;
  297. }
  298. module.exports = exports['default'];
  299. /***/ }),
  300. /* 3 */
  301. /***/ (function(module, exports) {
  302. // turn {x: {val: 1, stiffness: 1, damping: 2}, y: 2} generated by
  303. // `{x: spring(1, {stiffness: 1, damping: 2}), y: 2}` into {x: 1, y: 2}
  304. 'use strict';
  305. exports.__esModule = true;
  306. exports['default'] = stripStyle;
  307. function stripStyle(style) {
  308. var ret = {};
  309. for (var key in style) {
  310. if (!Object.prototype.hasOwnProperty.call(style, key)) {
  311. continue;
  312. }
  313. ret[key] = typeof style[key] === 'number' ? style[key] : style[key].val;
  314. }
  315. return ret;
  316. }
  317. module.exports = exports['default'];
  318. /***/ }),
  319. /* 4 */
  320. /***/ (function(module, exports) {
  321. // stepper is used a lot. Saves allocation to return the same array wrapper.
  322. // This is fine and danger-free against mutations because the callsite
  323. // immediately destructures it and gets the numbers inside without passing the
  324. "use strict";
  325. exports.__esModule = true;
  326. exports["default"] = stepper;
  327. var reusedTuple = [0, 0];
  328. function stepper(secondPerFrame, x, v, destX, k, b, precision) {
  329. // Spring stiffness, in kg / s^2
  330. // for animations, destX is really spring length (spring at rest). initial
  331. // position is considered as the stretched/compressed position of a spring
  332. var Fspring = -k * (x - destX);
  333. // Damping, in kg / s
  334. var Fdamper = -b * v;
  335. // usually we put mass here, but for animation purposes, specifying mass is a
  336. // bit redundant. you could simply adjust k and b accordingly
  337. // let a = (Fspring + Fdamper) / mass;
  338. var a = Fspring + Fdamper;
  339. var newV = v + a * secondPerFrame;
  340. var newX = x + newV * secondPerFrame;
  341. if (Math.abs(newV) < precision && Math.abs(newX - destX) < precision) {
  342. reusedTuple[0] = destX;
  343. reusedTuple[1] = 0;
  344. return reusedTuple;
  345. }
  346. reusedTuple[0] = newX;
  347. reusedTuple[1] = newV;
  348. return reusedTuple;
  349. }
  350. module.exports = exports["default"];
  351. // array reference around.
  352. /***/ }),
  353. /* 5 */
  354. /***/ (function(module, exports, __webpack_require__) {
  355. /* WEBPACK VAR INJECTION */(function(process) {// Generated by CoffeeScript 1.7.1
  356. "use strict";
  357. (function () {
  358. var getNanoSeconds, hrtime, loadTime;
  359. if (typeof performance !== "undefined" && performance !== null && performance.now) {
  360. module.exports = function () {
  361. return performance.now();
  362. };
  363. } else if (typeof process !== "undefined" && process !== null && process.hrtime) {
  364. module.exports = function () {
  365. return (getNanoSeconds() - loadTime) / 1e6;
  366. };
  367. hrtime = process.hrtime;
  368. getNanoSeconds = function () {
  369. var hr;
  370. hr = hrtime();
  371. return hr[0] * 1e9 + hr[1];
  372. };
  373. loadTime = getNanoSeconds();
  374. } else if (Date.now) {
  375. module.exports = function () {
  376. return Date.now() - loadTime;
  377. };
  378. loadTime = Date.now();
  379. } else {
  380. module.exports = function () {
  381. return new Date().getTime() - loadTime;
  382. };
  383. loadTime = new Date().getTime();
  384. }
  385. }).call(undefined);
  386. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  387. /***/ }),
  388. /* 6 */
  389. /***/ (function(module, exports) {
  390. // shim for using process in browser
  391. 'use strict';
  392. var process = module.exports = {};
  393. // cached from whatever global is present so that test runners that stub it
  394. // don't break things. But we need to wrap it in a try catch in case it is
  395. // wrapped in strict mode code which doesn't define any globals. It's inside a
  396. // function because try/catches deoptimize in certain engines.
  397. var cachedSetTimeout;
  398. var cachedClearTimeout;
  399. function defaultSetTimout() {
  400. throw new Error('setTimeout has not been defined');
  401. }
  402. function defaultClearTimeout() {
  403. throw new Error('clearTimeout has not been defined');
  404. }
  405. (function () {
  406. try {
  407. if (typeof setTimeout === 'function') {
  408. cachedSetTimeout = setTimeout;
  409. } else {
  410. cachedSetTimeout = defaultSetTimout;
  411. }
  412. } catch (e) {
  413. cachedSetTimeout = defaultSetTimout;
  414. }
  415. try {
  416. if (typeof clearTimeout === 'function') {
  417. cachedClearTimeout = clearTimeout;
  418. } else {
  419. cachedClearTimeout = defaultClearTimeout;
  420. }
  421. } catch (e) {
  422. cachedClearTimeout = defaultClearTimeout;
  423. }
  424. })();
  425. function runTimeout(fun) {
  426. if (cachedSetTimeout === setTimeout) {
  427. //normal enviroments in sane situations
  428. return setTimeout(fun, 0);
  429. }
  430. // if setTimeout wasn't available but was latter defined
  431. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  432. cachedSetTimeout = setTimeout;
  433. return setTimeout(fun, 0);
  434. }
  435. try {
  436. // when when somebody has screwed with setTimeout but no I.E. maddness
  437. return cachedSetTimeout(fun, 0);
  438. } catch (e) {
  439. try {
  440. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  441. return cachedSetTimeout.call(null, fun, 0);
  442. } catch (e) {
  443. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  444. return cachedSetTimeout.call(this, fun, 0);
  445. }
  446. }
  447. }
  448. function runClearTimeout(marker) {
  449. if (cachedClearTimeout === clearTimeout) {
  450. //normal enviroments in sane situations
  451. return clearTimeout(marker);
  452. }
  453. // if clearTimeout wasn't available but was latter defined
  454. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  455. cachedClearTimeout = clearTimeout;
  456. return clearTimeout(marker);
  457. }
  458. try {
  459. // when when somebody has screwed with setTimeout but no I.E. maddness
  460. return cachedClearTimeout(marker);
  461. } catch (e) {
  462. try {
  463. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  464. return cachedClearTimeout.call(null, marker);
  465. } catch (e) {
  466. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  467. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  468. return cachedClearTimeout.call(this, marker);
  469. }
  470. }
  471. }
  472. var queue = [];
  473. var draining = false;
  474. var currentQueue;
  475. var queueIndex = -1;
  476. function cleanUpNextTick() {
  477. if (!draining || !currentQueue) {
  478. return;
  479. }
  480. draining = false;
  481. if (currentQueue.length) {
  482. queue = currentQueue.concat(queue);
  483. } else {
  484. queueIndex = -1;
  485. }
  486. if (queue.length) {
  487. drainQueue();
  488. }
  489. }
  490. function drainQueue() {
  491. if (draining) {
  492. return;
  493. }
  494. var timeout = runTimeout(cleanUpNextTick);
  495. draining = true;
  496. var len = queue.length;
  497. while (len) {
  498. currentQueue = queue;
  499. queue = [];
  500. while (++queueIndex < len) {
  501. if (currentQueue) {
  502. currentQueue[queueIndex].run();
  503. }
  504. }
  505. queueIndex = -1;
  506. len = queue.length;
  507. }
  508. currentQueue = null;
  509. draining = false;
  510. runClearTimeout(timeout);
  511. }
  512. process.nextTick = function (fun) {
  513. var args = new Array(arguments.length - 1);
  514. if (arguments.length > 1) {
  515. for (var i = 1; i < arguments.length; i++) {
  516. args[i - 1] = arguments[i];
  517. }
  518. }
  519. queue.push(new Item(fun, args));
  520. if (queue.length === 1 && !draining) {
  521. runTimeout(drainQueue);
  522. }
  523. };
  524. // v8 likes predictible objects
  525. function Item(fun, array) {
  526. this.fun = fun;
  527. this.array = array;
  528. }
  529. Item.prototype.run = function () {
  530. this.fun.apply(null, this.array);
  531. };
  532. process.title = 'browser';
  533. process.browser = true;
  534. process.env = {};
  535. process.argv = [];
  536. process.version = ''; // empty string to avoid regexp issues
  537. process.versions = {};
  538. function noop() {}
  539. process.on = noop;
  540. process.addListener = noop;
  541. process.once = noop;
  542. process.off = noop;
  543. process.removeListener = noop;
  544. process.removeAllListeners = noop;
  545. process.emit = noop;
  546. process.prependListener = noop;
  547. process.prependOnceListener = noop;
  548. process.listeners = function (name) {
  549. return [];
  550. };
  551. process.binding = function (name) {
  552. throw new Error('process.binding is not supported');
  553. };
  554. process.cwd = function () {
  555. return '/';
  556. };
  557. process.chdir = function (dir) {
  558. throw new Error('process.chdir is not supported');
  559. };
  560. process.umask = function () {
  561. return 0;
  562. };
  563. /***/ }),
  564. /* 7 */
  565. /***/ (function(module, exports, __webpack_require__) {
  566. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  567. var now = __webpack_require__(8),
  568. root = typeof window === 'undefined' ? global : window,
  569. vendors = ['moz', 'webkit'],
  570. suffix = 'AnimationFrame',
  571. raf = root['request' + suffix],
  572. caf = root['cancel' + suffix] || root['cancelRequest' + suffix];
  573. for (var i = 0; !raf && i < vendors.length; i++) {
  574. raf = root[vendors[i] + 'Request' + suffix];
  575. caf = root[vendors[i] + 'Cancel' + suffix] || root[vendors[i] + 'CancelRequest' + suffix];
  576. }
  577. // Some versions of FF have rAF but not cAF
  578. if (!raf || !caf) {
  579. var last = 0,
  580. id = 0,
  581. queue = [],
  582. frameDuration = 1000 / 60;
  583. raf = function (callback) {
  584. if (queue.length === 0) {
  585. var _now = now(),
  586. next = Math.max(0, frameDuration - (_now - last));
  587. last = next + _now;
  588. setTimeout(function () {
  589. var cp = queue.slice(0);
  590. // Clear queue here to prevent
  591. // callbacks from appending listeners
  592. // to the current frame's queue
  593. queue.length = 0;
  594. for (var i = 0; i < cp.length; i++) {
  595. if (!cp[i].cancelled) {
  596. try {
  597. cp[i].callback(last);
  598. } catch (e) {
  599. setTimeout(function () {
  600. throw e;
  601. }, 0);
  602. }
  603. }
  604. }
  605. }, Math.round(next));
  606. }
  607. queue.push({
  608. handle: ++id,
  609. callback: callback,
  610. cancelled: false
  611. });
  612. return id;
  613. };
  614. caf = function (handle) {
  615. for (var i = 0; i < queue.length; i++) {
  616. if (queue[i].handle === handle) {
  617. queue[i].cancelled = true;
  618. }
  619. }
  620. };
  621. }
  622. module.exports = function (fn) {
  623. // Wrap in a new function to prevent
  624. // `cancel` potentially being assigned
  625. // to the native rAF function
  626. return raf.call(root, fn);
  627. };
  628. module.exports.cancel = function () {
  629. caf.apply(root, arguments);
  630. };
  631. module.exports.polyfill = function (object) {
  632. if (!object) {
  633. object = root;
  634. }
  635. object.requestAnimationFrame = raf;
  636. object.cancelAnimationFrame = caf;
  637. };
  638. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  639. /***/ }),
  640. /* 8 */
  641. /***/ (function(module, exports, __webpack_require__) {
  642. /* WEBPACK VAR INJECTION */(function(process) {// Generated by CoffeeScript 1.12.2
  643. "use strict";
  644. (function () {
  645. var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
  646. if (typeof performance !== "undefined" && performance !== null && performance.now) {
  647. module.exports = function () {
  648. return performance.now();
  649. };
  650. } else if (typeof process !== "undefined" && process !== null && process.hrtime) {
  651. module.exports = function () {
  652. return (getNanoSeconds() - nodeLoadTime) / 1e6;
  653. };
  654. hrtime = process.hrtime;
  655. getNanoSeconds = function () {
  656. var hr;
  657. hr = hrtime();
  658. return hr[0] * 1e9 + hr[1];
  659. };
  660. moduleLoadTime = getNanoSeconds();
  661. upTime = process.uptime() * 1e9;
  662. nodeLoadTime = moduleLoadTime - upTime;
  663. } else if (Date.now) {
  664. module.exports = function () {
  665. return Date.now() - loadTime;
  666. };
  667. loadTime = Date.now();
  668. } else {
  669. module.exports = function () {
  670. return new Date().getTime() - loadTime;
  671. };
  672. loadTime = new Date().getTime();
  673. }
  674. }).call(undefined);
  675. //# sourceMappingURL=performance-now.js.map
  676. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  677. /***/ }),
  678. /* 9 */
  679. /***/ (function(module, exports) {
  680. // usage assumption: currentStyle values have already been rendered but it says
  681. // nothing of whether currentStyle is stale (see unreadPropStyle)
  682. 'use strict';
  683. exports.__esModule = true;
  684. exports['default'] = shouldStopAnimation;
  685. function shouldStopAnimation(currentStyle, style, currentVelocity) {
  686. for (var key in style) {
  687. if (!Object.prototype.hasOwnProperty.call(style, key)) {
  688. continue;
  689. }
  690. if (currentVelocity[key] !== 0) {
  691. return false;
  692. }
  693. var styleValue = typeof style[key] === 'number' ? style[key] : style[key].val;
  694. // stepper will have already taken care of rounding precision errors, so
  695. // won't have such thing as 0.9999 !=== 1
  696. if (currentStyle[key] !== styleValue) {
  697. return false;
  698. }
  699. }
  700. return true;
  701. }
  702. module.exports = exports['default'];
  703. /***/ }),
  704. /* 10 */
  705. /***/ (function(module, exports) {
  706. module.exports = __WEBPACK_EXTERNAL_MODULE_10__;
  707. /***/ }),
  708. /* 11 */
  709. /***/ (function(module, exports, __webpack_require__) {
  710. /* WEBPACK VAR INJECTION */(function(process) {/**
  711. * Copyright (c) 2013-present, Facebook, Inc.
  712. *
  713. * This source code is licensed under the MIT license found in the
  714. * LICENSE file in the root directory of this source tree.
  715. */
  716. 'use strict';
  717. if (process.env.NODE_ENV !== 'production') {
  718. var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
  719. var isValidElement = function isValidElement(object) {
  720. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  721. };
  722. // By explicitly using `prop-types` you are opting into new development behavior.
  723. // http://fb.me/prop-types-in-prod
  724. var throwOnDirectAccess = true;
  725. module.exports = __webpack_require__(12)(isValidElement, throwOnDirectAccess);
  726. } else {
  727. // By explicitly using `prop-types` you are opting into new production behavior.
  728. // http://fb.me/prop-types-in-prod
  729. module.exports = __webpack_require__(19)();
  730. }
  731. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  732. /***/ }),
  733. /* 12 */
  734. /***/ (function(module, exports, __webpack_require__) {
  735. /* WEBPACK VAR INJECTION */(function(process) {/**
  736. * Copyright (c) 2013-present, Facebook, Inc.
  737. *
  738. * This source code is licensed under the MIT license found in the
  739. * LICENSE file in the root directory of this source tree.
  740. */
  741. 'use strict';
  742. var emptyFunction = __webpack_require__(13);
  743. var invariant = __webpack_require__(14);
  744. var warning = __webpack_require__(15);
  745. var assign = __webpack_require__(16);
  746. var ReactPropTypesSecret = __webpack_require__(17);
  747. var checkPropTypes = __webpack_require__(18);
  748. module.exports = function (isValidElement, throwOnDirectAccess) {
  749. /* global Symbol */
  750. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  751. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  752. /**
  753. * Returns the iterator method function contained on the iterable object.
  754. *
  755. * Be sure to invoke the function with the iterable as context:
  756. *
  757. * var iteratorFn = getIteratorFn(myIterable);
  758. * if (iteratorFn) {
  759. * var iterator = iteratorFn.call(myIterable);
  760. * ...
  761. * }
  762. *
  763. * @param {?object} maybeIterable
  764. * @return {?function}
  765. */
  766. function getIteratorFn(maybeIterable) {
  767. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  768. if (typeof iteratorFn === 'function') {
  769. return iteratorFn;
  770. }
  771. }
  772. /**
  773. * Collection of methods that allow declaration and validation of props that are
  774. * supplied to React components. Example usage:
  775. *
  776. * var Props = require('ReactPropTypes');
  777. * var MyArticle = React.createClass({
  778. * propTypes: {
  779. * // An optional string prop named "description".
  780. * description: Props.string,
  781. *
  782. * // A required enum prop named "category".
  783. * category: Props.oneOf(['News','Photos']).isRequired,
  784. *
  785. * // A prop named "dialog" that requires an instance of Dialog.
  786. * dialog: Props.instanceOf(Dialog).isRequired
  787. * },
  788. * render: function() { ... }
  789. * });
  790. *
  791. * A more formal specification of how these methods are used:
  792. *
  793. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  794. * decl := ReactPropTypes.{type}(.isRequired)?
  795. *
  796. * Each and every declaration produces a function with the same signature. This
  797. * allows the creation of custom validation functions. For example:
  798. *
  799. * var MyLink = React.createClass({
  800. * propTypes: {
  801. * // An optional string or URI prop named "href".
  802. * href: function(props, propName, componentName) {
  803. * var propValue = props[propName];
  804. * if (propValue != null && typeof propValue !== 'string' &&
  805. * !(propValue instanceof URI)) {
  806. * return new Error(
  807. * 'Expected a string or an URI for ' + propName + ' in ' +
  808. * componentName
  809. * );
  810. * }
  811. * }
  812. * },
  813. * render: function() {...}
  814. * });
  815. *
  816. * @internal
  817. */
  818. var ANONYMOUS = '<<anonymous>>';
  819. // Important!
  820. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  821. var ReactPropTypes = {
  822. array: createPrimitiveTypeChecker('array'),
  823. bool: createPrimitiveTypeChecker('boolean'),
  824. func: createPrimitiveTypeChecker('function'),
  825. number: createPrimitiveTypeChecker('number'),
  826. object: createPrimitiveTypeChecker('object'),
  827. string: createPrimitiveTypeChecker('string'),
  828. symbol: createPrimitiveTypeChecker('symbol'),
  829. any: createAnyTypeChecker(),
  830. arrayOf: createArrayOfTypeChecker,
  831. element: createElementTypeChecker(),
  832. instanceOf: createInstanceTypeChecker,
  833. node: createNodeChecker(),
  834. objectOf: createObjectOfTypeChecker,
  835. oneOf: createEnumTypeChecker,
  836. oneOfType: createUnionTypeChecker,
  837. shape: createShapeTypeChecker,
  838. exact: createStrictShapeTypeChecker
  839. };
  840. /**
  841. * inlined Object.is polyfill to avoid requiring consumers ship their own
  842. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  843. */
  844. /*eslint-disable no-self-compare*/
  845. function is(x, y) {
  846. // SameValue algorithm
  847. if (x === y) {
  848. // Steps 1-5, 7-10
  849. // Steps 6.b-6.e: +0 != -0
  850. return x !== 0 || 1 / x === 1 / y;
  851. } else {
  852. // Step 6.a: NaN == NaN
  853. return x !== x && y !== y;
  854. }
  855. }
  856. /*eslint-enable no-self-compare*/
  857. /**
  858. * We use an Error-like object for backward compatibility as people may call
  859. * PropTypes directly and inspect their output. However, we don't use real
  860. * Errors anymore. We don't inspect their stack anyway, and creating them
  861. * is prohibitively expensive if they are created too often, such as what
  862. * happens in oneOfType() for any type before the one that matched.
  863. */
  864. function PropTypeError(message) {
  865. this.message = message;
  866. this.stack = '';
  867. }
  868. // Make `instanceof Error` still work for returned errors.
  869. PropTypeError.prototype = Error.prototype;
  870. function createChainableTypeChecker(validate) {
  871. if (process.env.NODE_ENV !== 'production') {
  872. var manualPropTypeCallCache = {};
  873. var manualPropTypeWarningCount = 0;
  874. }
  875. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  876. componentName = componentName || ANONYMOUS;
  877. propFullName = propFullName || propName;
  878. if (secret !== ReactPropTypesSecret) {
  879. if (throwOnDirectAccess) {
  880. // New behavior only for users of `prop-types` package
  881. invariant(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
  882. } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
  883. // Old behavior for people using React.PropTypes
  884. var cacheKey = componentName + ':' + propName;
  885. if (!manualPropTypeCallCache[cacheKey] &&
  886. // Avoid spamming the console because they are often not actionable except for lib authors
  887. manualPropTypeWarningCount < 3) {
  888. warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName);
  889. manualPropTypeCallCache[cacheKey] = true;
  890. manualPropTypeWarningCount++;
  891. }
  892. }
  893. }
  894. if (props[propName] == null) {
  895. if (isRequired) {
  896. if (props[propName] === null) {
  897. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  898. }
  899. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  900. }
  901. return null;
  902. } else {
  903. return validate(props, propName, componentName, location, propFullName);
  904. }
  905. }
  906. var chainedCheckType = checkType.bind(null, false);
  907. chainedCheckType.isRequired = checkType.bind(null, true);
  908. return chainedCheckType;
  909. }
  910. function createPrimitiveTypeChecker(expectedType) {
  911. function validate(props, propName, componentName, location, propFullName, secret) {
  912. var propValue = props[propName];
  913. var propType = getPropType(propValue);
  914. if (propType !== expectedType) {
  915. // `propValue` being instance of, say, date/regexp, pass the 'object'
  916. // check, but we can offer a more precise error message here rather than
  917. // 'of type `object`'.
  918. var preciseType = getPreciseType(propValue);
  919. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  920. }
  921. return null;
  922. }
  923. return createChainableTypeChecker(validate);
  924. }
  925. function createAnyTypeChecker() {
  926. return createChainableTypeChecker(emptyFunction.thatReturnsNull);
  927. }
  928. function createArrayOfTypeChecker(typeChecker) {
  929. function validate(props, propName, componentName, location, propFullName) {
  930. if (typeof typeChecker !== 'function') {
  931. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  932. }
  933. var propValue = props[propName];
  934. if (!Array.isArray(propValue)) {
  935. var propType = getPropType(propValue);
  936. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  937. }
  938. for (var i = 0; i < propValue.length; i++) {
  939. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
  940. if (error instanceof Error) {
  941. return error;
  942. }
  943. }
  944. return null;
  945. }
  946. return createChainableTypeChecker(validate);
  947. }
  948. function createElementTypeChecker() {
  949. function validate(props, propName, componentName, location, propFullName) {
  950. var propValue = props[propName];
  951. if (!isValidElement(propValue)) {
  952. var propType = getPropType(propValue);
  953. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  954. }
  955. return null;
  956. }
  957. return createChainableTypeChecker(validate);
  958. }
  959. function createInstanceTypeChecker(expectedClass) {
  960. function validate(props, propName, componentName, location, propFullName) {
  961. if (!(props[propName] instanceof expectedClass)) {
  962. var expectedClassName = expectedClass.name || ANONYMOUS;
  963. var actualClassName = getClassName(props[propName]);
  964. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  965. }
  966. return null;
  967. }
  968. return createChainableTypeChecker(validate);
  969. }
  970. function createEnumTypeChecker(expectedValues) {
  971. if (!Array.isArray(expectedValues)) {
  972. process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
  973. return emptyFunction.thatReturnsNull;
  974. }
  975. function validate(props, propName, componentName, location, propFullName) {
  976. var propValue = props[propName];
  977. for (var i = 0; i < expectedValues.length; i++) {
  978. if (is(propValue, expectedValues[i])) {
  979. return null;
  980. }
  981. }
  982. var valuesString = JSON.stringify(expectedValues);
  983. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  984. }
  985. return createChainableTypeChecker(validate);
  986. }
  987. function createObjectOfTypeChecker(typeChecker) {
  988. function validate(props, propName, componentName, location, propFullName) {
  989. if (typeof typeChecker !== 'function') {
  990. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  991. }
  992. var propValue = props[propName];
  993. var propType = getPropType(propValue);
  994. if (propType !== 'object') {
  995. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  996. }
  997. for (var key in propValue) {
  998. if (propValue.hasOwnProperty(key)) {
  999. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  1000. if (error instanceof Error) {
  1001. return error;
  1002. }
  1003. }
  1004. }
  1005. return null;
  1006. }
  1007. return createChainableTypeChecker(validate);
  1008. }
  1009. function createUnionTypeChecker(arrayOfTypeCheckers) {
  1010. if (!Array.isArray(arrayOfTypeCheckers)) {
  1011. process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
  1012. return emptyFunction.thatReturnsNull;
  1013. }
  1014. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  1015. var checker = arrayOfTypeCheckers[i];
  1016. if (typeof checker !== 'function') {
  1017. warning(false, 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received %s at index %s.', getPostfixForTypeWarning(checker), i);
  1018. return emptyFunction.thatReturnsNull;
  1019. }
  1020. }
  1021. function validate(props, propName, componentName, location, propFullName) {
  1022. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  1023. var checker = arrayOfTypeCheckers[i];
  1024. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
  1025. return null;
  1026. }
  1027. }
  1028. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  1029. }
  1030. return createChainableTypeChecker(validate);
  1031. }
  1032. function createNodeChecker() {
  1033. function validate(props, propName, componentName, location, propFullName) {
  1034. if (!isNode(props[propName])) {
  1035. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  1036. }
  1037. return null;
  1038. }
  1039. return createChainableTypeChecker(validate);
  1040. }
  1041. function createShapeTypeChecker(shapeTypes) {
  1042. function validate(props, propName, componentName, location, propFullName) {
  1043. var propValue = props[propName];
  1044. var propType = getPropType(propValue);
  1045. if (propType !== 'object') {
  1046. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  1047. }
  1048. for (var key in shapeTypes) {
  1049. var checker = shapeTypes[key];
  1050. if (!checker) {
  1051. continue;
  1052. }
  1053. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  1054. if (error) {
  1055. return error;
  1056. }
  1057. }
  1058. return null;
  1059. }
  1060. return createChainableTypeChecker(validate);
  1061. }
  1062. function createStrictShapeTypeChecker(shapeTypes) {
  1063. function validate(props, propName, componentName, location, propFullName) {
  1064. var propValue = props[propName];
  1065. var propType = getPropType(propValue);
  1066. if (propType !== 'object') {
  1067. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  1068. }
  1069. // We need to check all keys in case some are required but missing from
  1070. // props.
  1071. var allKeys = assign({}, props[propName], shapeTypes);
  1072. for (var key in allKeys) {
  1073. var checker = shapeTypes[key];
  1074. if (!checker) {
  1075. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' '));
  1076. }
  1077. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  1078. if (error) {
  1079. return error;
  1080. }
  1081. }
  1082. return null;
  1083. }
  1084. return createChainableTypeChecker(validate);
  1085. }
  1086. function isNode(propValue) {
  1087. switch (typeof propValue) {
  1088. case 'number':
  1089. case 'string':
  1090. case 'undefined':
  1091. return true;
  1092. case 'boolean':
  1093. return !propValue;
  1094. case 'object':
  1095. if (Array.isArray(propValue)) {
  1096. return propValue.every(isNode);
  1097. }
  1098. if (propValue === null || isValidElement(propValue)) {
  1099. return true;
  1100. }
  1101. var iteratorFn = getIteratorFn(propValue);
  1102. if (iteratorFn) {
  1103. var iterator = iteratorFn.call(propValue);
  1104. var step;
  1105. if (iteratorFn !== propValue.entries) {
  1106. while (!(step = iterator.next()).done) {
  1107. if (!isNode(step.value)) {
  1108. return false;
  1109. }
  1110. }
  1111. } else {
  1112. // Iterator will provide entry [k,v] tuples rather than values.
  1113. while (!(step = iterator.next()).done) {
  1114. var entry = step.value;
  1115. if (entry) {
  1116. if (!isNode(entry[1])) {
  1117. return false;
  1118. }
  1119. }
  1120. }
  1121. }
  1122. } else {
  1123. return false;
  1124. }
  1125. return true;
  1126. default:
  1127. return false;
  1128. }
  1129. }
  1130. function isSymbol(propType, propValue) {
  1131. // Native Symbol.
  1132. if (propType === 'symbol') {
  1133. return true;
  1134. }
  1135. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  1136. if (propValue['@@toStringTag'] === 'Symbol') {
  1137. return true;
  1138. }
  1139. // Fallback for non-spec compliant Symbols which are polyfilled.
  1140. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  1141. return true;
  1142. }
  1143. return false;
  1144. }
  1145. // Equivalent of `typeof` but with special handling for array and regexp.
  1146. function getPropType(propValue) {
  1147. var propType = typeof propValue;
  1148. if (Array.isArray(propValue)) {
  1149. return 'array';
  1150. }
  1151. if (propValue instanceof RegExp) {
  1152. // Old webkits (at least until Android 4.0) return 'function' rather than
  1153. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  1154. // passes PropTypes.object.
  1155. return 'object';
  1156. }
  1157. if (isSymbol(propType, propValue)) {
  1158. return 'symbol';
  1159. }
  1160. return propType;
  1161. }
  1162. // This handles more types than `getPropType`. Only used for error messages.
  1163. // See `createPrimitiveTypeChecker`.
  1164. function getPreciseType(propValue) {
  1165. if (typeof propValue === 'undefined' || propValue === null) {
  1166. return '' + propValue;
  1167. }
  1168. var propType = getPropType(propValue);
  1169. if (propType === 'object') {
  1170. if (propValue instanceof Date) {
  1171. return 'date';
  1172. } else if (propValue instanceof RegExp) {
  1173. return 'regexp';
  1174. }
  1175. }
  1176. return propType;
  1177. }
  1178. // Returns a string that is postfixed to a warning about an invalid type.
  1179. // For example, "undefined" or "of type array"
  1180. function getPostfixForTypeWarning(value) {
  1181. var type = getPreciseType(value);
  1182. switch (type) {
  1183. case 'array':
  1184. case 'object':
  1185. return 'an ' + type;
  1186. case 'boolean':
  1187. case 'date':
  1188. case 'regexp':
  1189. return 'a ' + type;
  1190. default:
  1191. return type;
  1192. }
  1193. }
  1194. // Returns class name of the object, if any.
  1195. function getClassName(propValue) {
  1196. if (!propValue.constructor || !propValue.constructor.name) {
  1197. return ANONYMOUS;
  1198. }
  1199. return propValue.constructor.name;
  1200. }
  1201. ReactPropTypes.checkPropTypes = checkPropTypes;
  1202. ReactPropTypes.PropTypes = ReactPropTypes;
  1203. return ReactPropTypes;
  1204. };
  1205. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  1206. /***/ }),
  1207. /* 13 */
  1208. /***/ (function(module, exports) {
  1209. "use strict";
  1210. /**
  1211. * Copyright (c) 2013-present, Facebook, Inc.
  1212. *
  1213. * This source code is licensed under the MIT license found in the
  1214. * LICENSE file in the root directory of this source tree.
  1215. *
  1216. *
  1217. */
  1218. function makeEmptyFunction(arg) {
  1219. return function () {
  1220. return arg;
  1221. };
  1222. }
  1223. /**
  1224. * This function accepts and discards inputs; it has no side effects. This is
  1225. * primarily useful idiomatically for overridable function endpoints which
  1226. * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
  1227. */
  1228. var emptyFunction = function emptyFunction() {};
  1229. emptyFunction.thatReturns = makeEmptyFunction;
  1230. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  1231. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  1232. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  1233. emptyFunction.thatReturnsThis = function () {
  1234. return this;
  1235. };
  1236. emptyFunction.thatReturnsArgument = function (arg) {
  1237. return arg;
  1238. };
  1239. module.exports = emptyFunction;
  1240. /***/ }),
  1241. /* 14 */
  1242. /***/ (function(module, exports, __webpack_require__) {
  1243. /* WEBPACK VAR INJECTION */(function(process) {/**
  1244. * Copyright (c) 2013-present, Facebook, Inc.
  1245. *
  1246. * This source code is licensed under the MIT license found in the
  1247. * LICENSE file in the root directory of this source tree.
  1248. *
  1249. */
  1250. 'use strict';
  1251. /**
  1252. * Use invariant() to assert state which your program assumes to be true.
  1253. *
  1254. * Provide sprintf-style format (only %s is supported) and arguments
  1255. * to provide information about what broke and what you were
  1256. * expecting.
  1257. *
  1258. * The invariant message will be stripped in production, but the invariant
  1259. * will remain to ensure logic does not differ in production.
  1260. */
  1261. var validateFormat = function validateFormat(format) {};
  1262. if (process.env.NODE_ENV !== 'production') {
  1263. validateFormat = function validateFormat(format) {
  1264. if (format === undefined) {
  1265. throw new Error('invariant requires an error message argument');
  1266. }
  1267. };
  1268. }
  1269. function invariant(condition, format, a, b, c, d, e, f) {
  1270. validateFormat(format);
  1271. if (!condition) {
  1272. var error;
  1273. if (format === undefined) {
  1274. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  1275. } else {
  1276. var args = [a, b, c, d, e, f];
  1277. var argIndex = 0;
  1278. error = new Error(format.replace(/%s/g, function () {
  1279. return args[argIndex++];
  1280. }));
  1281. error.name = 'Invariant Violation';
  1282. }
  1283. error.framesToPop = 1; // we don't care about invariant's own frame
  1284. throw error;
  1285. }
  1286. }
  1287. module.exports = invariant;
  1288. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  1289. /***/ }),
  1290. /* 15 */
  1291. /***/ (function(module, exports, __webpack_require__) {
  1292. /* WEBPACK VAR INJECTION */(function(process) {/**
  1293. * Copyright (c) 2014-present, Facebook, Inc.
  1294. *
  1295. * This source code is licensed under the MIT license found in the
  1296. * LICENSE file in the root directory of this source tree.
  1297. *
  1298. */
  1299. 'use strict';
  1300. var emptyFunction = __webpack_require__(13);
  1301. /**
  1302. * Similar to invariant but only logs a warning if the condition is not met.
  1303. * This can be used to log issues in development environments in critical
  1304. * paths. Removing the logging code for production environments will keep the
  1305. * same logic and follow the same code paths.
  1306. */
  1307. var warning = emptyFunction;
  1308. if (process.env.NODE_ENV !== 'production') {
  1309. var printWarning = function printWarning(format) {
  1310. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1311. args[_key - 1] = arguments[_key];
  1312. }
  1313. var argIndex = 0;
  1314. var message = 'Warning: ' + format.replace(/%s/g, function () {
  1315. return args[argIndex++];
  1316. });
  1317. if (typeof console !== 'undefined') {
  1318. console.error(message);
  1319. }
  1320. try {
  1321. // --- Welcome to debugging React ---
  1322. // This error was thrown as a convenience so that you can use this stack
  1323. // to find the callsite that caused this warning to fire.
  1324. throw new Error(message);
  1325. } catch (x) {}
  1326. };
  1327. warning = function warning(condition, format) {
  1328. if (format === undefined) {
  1329. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  1330. }
  1331. if (format.indexOf('Failed Composite propType: ') === 0) {
  1332. return; // Ignore CompositeComponent proptype check.
  1333. }
  1334. if (!condition) {
  1335. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  1336. args[_key2 - 2] = arguments[_key2];
  1337. }
  1338. printWarning.apply(undefined, [format].concat(args));
  1339. }
  1340. };
  1341. }
  1342. module.exports = warning;
  1343. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  1344. /***/ }),
  1345. /* 16 */
  1346. /***/ (function(module, exports) {
  1347. /*
  1348. object-assign
  1349. (c) Sindre Sorhus
  1350. @license MIT
  1351. */
  1352. 'use strict';
  1353. /* eslint-disable no-unused-vars */
  1354. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  1355. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1356. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  1357. function toObject(val) {
  1358. if (val === null || val === undefined) {
  1359. throw new TypeError('Object.assign cannot be called with null or undefined');
  1360. }
  1361. return Object(val);
  1362. }
  1363. function shouldUseNative() {
  1364. try {
  1365. if (!Object.assign) {
  1366. return false;
  1367. }
  1368. // Detect buggy property enumeration order in older V8 versions.
  1369. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  1370. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  1371. test1[5] = 'de';
  1372. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  1373. return false;
  1374. }
  1375. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  1376. var test2 = {};
  1377. for (var i = 0; i < 10; i++) {
  1378. test2['_' + String.fromCharCode(i)] = i;
  1379. }
  1380. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  1381. return test2[n];
  1382. });
  1383. if (order2.join('') !== '0123456789') {
  1384. return false;
  1385. }
  1386. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  1387. var test3 = {};
  1388. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  1389. test3[letter] = letter;
  1390. });
  1391. if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
  1392. return false;
  1393. }
  1394. return true;
  1395. } catch (err) {
  1396. // We don't expect any of the above to throw, but better to be safe.
  1397. return false;
  1398. }
  1399. }
  1400. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  1401. var from;
  1402. var to = toObject(target);
  1403. var symbols;
  1404. for (var s = 1; s < arguments.length; s++) {
  1405. from = Object(arguments[s]);
  1406. for (var key in from) {
  1407. if (hasOwnProperty.call(from, key)) {
  1408. to[key] = from[key];
  1409. }
  1410. }
  1411. if (getOwnPropertySymbols) {
  1412. symbols = getOwnPropertySymbols(from);
  1413. for (var i = 0; i < symbols.length; i++) {
  1414. if (propIsEnumerable.call(from, symbols[i])) {
  1415. to[symbols[i]] = from[symbols[i]];
  1416. }
  1417. }
  1418. }
  1419. }
  1420. return to;
  1421. };
  1422. /***/ }),
  1423. /* 17 */
  1424. /***/ (function(module, exports) {
  1425. /**
  1426. * Copyright (c) 2013-present, Facebook, Inc.
  1427. *
  1428. * This source code is licensed under the MIT license found in the
  1429. * LICENSE file in the root directory of this source tree.
  1430. */
  1431. 'use strict';
  1432. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  1433. module.exports = ReactPropTypesSecret;
  1434. /***/ }),
  1435. /* 18 */
  1436. /***/ (function(module, exports, __webpack_require__) {
  1437. /* WEBPACK VAR INJECTION */(function(process) {/**
  1438. * Copyright (c) 2013-present, Facebook, Inc.
  1439. *
  1440. * This source code is licensed under the MIT license found in the
  1441. * LICENSE file in the root directory of this source tree.
  1442. */
  1443. 'use strict';
  1444. if (process.env.NODE_ENV !== 'production') {
  1445. var invariant = __webpack_require__(14);
  1446. var warning = __webpack_require__(15);
  1447. var ReactPropTypesSecret = __webpack_require__(17);
  1448. var loggedTypeFailures = {};
  1449. }
  1450. /**
  1451. * Assert that the values match with the type specs.
  1452. * Error messages are memorized and will only be shown once.
  1453. *
  1454. * @param {object} typeSpecs Map of name to a ReactPropType
  1455. * @param {object} values Runtime values that need to be type-checked
  1456. * @param {string} location e.g. "prop", "context", "child context"
  1457. * @param {string} componentName Name of the component for error messages.
  1458. * @param {?Function} getStack Returns the component stack.
  1459. * @private
  1460. */
  1461. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  1462. if (process.env.NODE_ENV !== 'production') {
  1463. for (var typeSpecName in typeSpecs) {
  1464. if (typeSpecs.hasOwnProperty(typeSpecName)) {
  1465. var error;
  1466. // Prop type validation may throw. In case they do, we don't want to
  1467. // fail the render phase where it didn't fail before. So we log it.
  1468. // After these have been cleaned up, we'll let them throw.
  1469. try {
  1470. // This is intentionally an invariant that gets caught. It's the same
  1471. // behavior as without this statement except with a better message.
  1472. invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
  1473. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  1474. } catch (ex) {
  1475. error = ex;
  1476. }
  1477. warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
  1478. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  1479. // Only monitor this failure once because there tends to be a lot of the
  1480. // same error.
  1481. loggedTypeFailures[error.message] = true;
  1482. var stack = getStack ? getStack() : '';
  1483. warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
  1484. }
  1485. }
  1486. }
  1487. }
  1488. }
  1489. module.exports = checkPropTypes;
  1490. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  1491. /***/ }),
  1492. /* 19 */
  1493. /***/ (function(module, exports, __webpack_require__) {
  1494. /**
  1495. * Copyright (c) 2013-present, Facebook, Inc.
  1496. *
  1497. * This source code is licensed under the MIT license found in the
  1498. * LICENSE file in the root directory of this source tree.
  1499. */
  1500. 'use strict';
  1501. var emptyFunction = __webpack_require__(13);
  1502. var invariant = __webpack_require__(14);
  1503. var ReactPropTypesSecret = __webpack_require__(17);
  1504. module.exports = function () {
  1505. function shim(props, propName, componentName, location, propFullName, secret) {
  1506. if (secret === ReactPropTypesSecret) {
  1507. // It is still safe when called from React.
  1508. return;
  1509. }
  1510. invariant(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
  1511. };
  1512. shim.isRequired = shim;
  1513. function getShim() {
  1514. return shim;
  1515. };
  1516. // Important!
  1517. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  1518. var ReactPropTypes = {
  1519. array: shim,
  1520. bool: shim,
  1521. func: shim,
  1522. number: shim,
  1523. object: shim,
  1524. string: shim,
  1525. symbol: shim,
  1526. any: shim,
  1527. arrayOf: getShim,
  1528. element: shim,
  1529. instanceOf: getShim,
  1530. node: shim,
  1531. objectOf: getShim,
  1532. oneOf: getShim,
  1533. oneOfType: getShim,
  1534. shape: getShim,
  1535. exact: getShim
  1536. };
  1537. ReactPropTypes.checkPropTypes = emptyFunction;
  1538. ReactPropTypes.PropTypes = ReactPropTypes;
  1539. return ReactPropTypes;
  1540. };
  1541. /***/ }),
  1542. /* 20 */
  1543. /***/ (function(module, exports, __webpack_require__) {
  1544. 'use strict';
  1545. exports.__esModule = true;
  1546. var _extends = Object.assign || function (target) { for (var i = 1; i < 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; };
  1547. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  1548. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  1549. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  1550. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1551. var _mapToZero = __webpack_require__(2);
  1552. var _mapToZero2 = _interopRequireDefault(_mapToZero);
  1553. var _stripStyle = __webpack_require__(3);
  1554. var _stripStyle2 = _interopRequireDefault(_stripStyle);
  1555. var _stepper3 = __webpack_require__(4);
  1556. var _stepper4 = _interopRequireDefault(_stepper3);
  1557. var _performanceNow = __webpack_require__(5);
  1558. var _performanceNow2 = _interopRequireDefault(_performanceNow);
  1559. var _raf = __webpack_require__(7);
  1560. var _raf2 = _interopRequireDefault(_raf);
  1561. var _shouldStopAnimation = __webpack_require__(9);
  1562. var _shouldStopAnimation2 = _interopRequireDefault(_shouldStopAnimation);
  1563. var _react = __webpack_require__(10);
  1564. var _react2 = _interopRequireDefault(_react);
  1565. var _propTypes = __webpack_require__(11);
  1566. var _propTypes2 = _interopRequireDefault(_propTypes);
  1567. var msPerFrame = 1000 / 60;
  1568. function shouldStopAnimationAll(currentStyles, styles, currentVelocities) {
  1569. for (var i = 0; i < currentStyles.length; i++) {
  1570. if (!_shouldStopAnimation2['default'](currentStyles[i], styles[i], currentVelocities[i])) {
  1571. return false;
  1572. }
  1573. }
  1574. return true;
  1575. }
  1576. var StaggeredMotion = (function (_React$Component) {
  1577. _inherits(StaggeredMotion, _React$Component);
  1578. _createClass(StaggeredMotion, null, [{
  1579. key: 'propTypes',
  1580. value: {
  1581. // TOOD: warn against putting a config in here
  1582. defaultStyles: _propTypes2['default'].arrayOf(_propTypes2['default'].objectOf(_propTypes2['default'].number)),
  1583. styles: _propTypes2['default'].func.isRequired,
  1584. children: _propTypes2['default'].func.isRequired
  1585. },
  1586. enumerable: true
  1587. }]);
  1588. function StaggeredMotion(props) {
  1589. var _this = this;
  1590. _classCallCheck(this, StaggeredMotion);
  1591. _React$Component.call(this, props);
  1592. this.animationID = null;
  1593. this.prevTime = 0;
  1594. this.accumulatedTime = 0;
  1595. this.unreadPropStyles = null;
  1596. this.clearUnreadPropStyle = function (unreadPropStyles) {
  1597. var _state = _this.state;
  1598. var currentStyles = _state.currentStyles;
  1599. var currentVelocities = _state.currentVelocities;
  1600. var lastIdealStyles = _state.lastIdealStyles;
  1601. var lastIdealVelocities = _state.lastIdealVelocities;
  1602. var someDirty = false;
  1603. for (var i = 0; i < unreadPropStyles.length; i++) {
  1604. var unreadPropStyle = unreadPropStyles[i];
  1605. var dirty = false;
  1606. for (var key in unreadPropStyle) {
  1607. if (!Object.prototype.hasOwnProperty.call(unreadPropStyle, key)) {
  1608. continue;
  1609. }
  1610. var styleValue = unreadPropStyle[key];
  1611. if (typeof styleValue === 'number') {
  1612. if (!dirty) {
  1613. dirty = true;
  1614. someDirty = true;
  1615. currentStyles[i] = _extends({}, currentStyles[i]);
  1616. currentVelocities[i] = _extends({}, currentVelocities[i]);
  1617. lastIdealStyles[i] = _extends({}, lastIdealStyles[i]);
  1618. lastIdealVelocities[i] = _extends({}, lastIdealVelocities[i]);
  1619. }
  1620. currentStyles[i][key] = styleValue;
  1621. currentVelocities[i][key] = 0;
  1622. lastIdealStyles[i][key] = styleValue;
  1623. lastIdealVelocities[i][key] = 0;
  1624. }
  1625. }
  1626. }
  1627. if (someDirty) {
  1628. _this.setState({ currentStyles: currentStyles, currentVelocities: currentVelocities, lastIdealStyles: lastIdealStyles, lastIdealVelocities: lastIdealVelocities });
  1629. }
  1630. };
  1631. this.startAnimationIfNecessary = function () {
  1632. // TODO: when config is {a: 10} and dest is {a: 10} do we raf once and
  1633. // call cb? No, otherwise accidental parent rerender causes cb trigger
  1634. _this.animationID = _raf2['default'](function (timestamp) {
  1635. var destStyles = _this.props.styles(_this.state.lastIdealStyles);
  1636. // check if we need to animate in the first place
  1637. if (shouldStopAnimationAll(_this.state.currentStyles, destStyles, _this.state.currentVelocities)) {
  1638. // no need to cancel animationID here; shouldn't have any in flight
  1639. _this.animationID = null;
  1640. _this.accumulatedTime = 0;
  1641. return;
  1642. }
  1643. var currentTime = timestamp || _performanceNow2['default']();
  1644. var timeDelta = currentTime - _this.prevTime;
  1645. _this.prevTime = currentTime;
  1646. _this.accumulatedTime = _this.accumulatedTime + timeDelta;
  1647. // more than 10 frames? prolly switched browser tab. Restart
  1648. if (_this.accumulatedTime > msPerFrame * 10) {
  1649. _this.accumulatedTime = 0;
  1650. }
  1651. if (_this.accumulatedTime === 0) {
  1652. // no need to cancel animationID here; shouldn't have any in flight
  1653. _this.animationID = null;
  1654. _this.startAnimationIfNecessary();
  1655. return;
  1656. }
  1657. var currentFrameCompletion = (_this.accumulatedTime - Math.floor(_this.accumulatedTime / msPerFrame) * msPerFrame) / msPerFrame;
  1658. var framesToCatchUp = Math.floor(_this.accumulatedTime / msPerFrame);
  1659. var newLastIdealStyles = [];
  1660. var newLastIdealVelocities = [];
  1661. var newCurrentStyles = [];
  1662. var newCurrentVelocities = [];
  1663. for (var i = 0; i < destStyles.length; i++) {
  1664. var destStyle = destStyles[i];
  1665. var newCurrentStyle = {};
  1666. var newCurrentVelocity = {};
  1667. var newLastIdealStyle = {};
  1668. var newLastIdealVelocity = {};
  1669. for (var key in destStyle) {
  1670. if (!Object.prototype.hasOwnProperty.call(destStyle, key)) {
  1671. continue;
  1672. }
  1673. var styleValue = destStyle[key];
  1674. if (typeof styleValue === 'number') {
  1675. newCurrentStyle[key] = styleValue;
  1676. newCurrentVelocity[key] = 0;
  1677. newLastIdealStyle[key] = styleValue;
  1678. newLastIdealVelocity[key] = 0;
  1679. } else {
  1680. var newLastIdealStyleValue = _this.state.lastIdealStyles[i][key];
  1681. var newLastIdealVelocityValue = _this.state.lastIdealVelocities[i][key];
  1682. for (var j = 0; j < framesToCatchUp; j++) {
  1683. var _stepper = _stepper4['default'](msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.stiffness, styleValue.damping, styleValue.precision);
  1684. newLastIdealStyleValue = _stepper[0];
  1685. newLastIdealVelocityValue = _stepper[1];
  1686. }
  1687. var _stepper2 = _stepper4['default'](msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.stiffness, styleValue.damping, styleValue.precision);
  1688. var nextIdealX = _stepper2[0];
  1689. var nextIdealV = _stepper2[1];
  1690. newCurrentStyle[key] = newLastIdealStyleValue + (nextIdealX - newLastIdealStyleValue) * currentFrameCompletion;
  1691. newCurrentVelocity[key] = newLastIdealVelocityValue + (nextIdealV - newLastIdealVelocityValue) * currentFrameCompletion;
  1692. newLastIdealStyle[key] = newLastIdealStyleValue;
  1693. newLastIdealVelocity[key] = newLastIdealVelocityValue;
  1694. }
  1695. }
  1696. newCurrentStyles[i] = newCurrentStyle;
  1697. newCurrentVelocities[i] = newCurrentVelocity;
  1698. newLastIdealStyles[i] = newLastIdealStyle;
  1699. newLastIdealVelocities[i] = newLastIdealVelocity;
  1700. }
  1701. _this.animationID = null;
  1702. // the amount we're looped over above
  1703. _this.accumulatedTime -= framesToCatchUp * msPerFrame;
  1704. _this.setState({
  1705. currentStyles: newCurrentStyles,
  1706. currentVelocities: newCurrentVelocities,
  1707. lastIdealStyles: newLastIdealStyles,
  1708. lastIdealVelocities: newLastIdealVelocities
  1709. });
  1710. _this.unreadPropStyles = null;
  1711. _this.startAnimationIfNecessary();
  1712. });
  1713. };
  1714. this.state = this.defaultState();
  1715. }
  1716. StaggeredMotion.prototype.defaultState = function defaultState() {
  1717. var _props = this.props;
  1718. var defaultStyles = _props.defaultStyles;
  1719. var styles = _props.styles;
  1720. var currentStyles = defaultStyles || styles().map(_stripStyle2['default']);
  1721. var currentVelocities = currentStyles.map(function (currentStyle) {
  1722. return _mapToZero2['default'](currentStyle);
  1723. });
  1724. return {
  1725. currentStyles: currentStyles,
  1726. currentVelocities: currentVelocities,
  1727. lastIdealStyles: currentStyles,
  1728. lastIdealVelocities: currentVelocities
  1729. };
  1730. };
  1731. StaggeredMotion.prototype.componentDidMount = function componentDidMount() {
  1732. this.prevTime = _performanceNow2['default']();
  1733. this.startAnimationIfNecessary();
  1734. };
  1735. StaggeredMotion.prototype.componentWillReceiveProps = function componentWillReceiveProps(props) {
  1736. if (this.unreadPropStyles != null) {
  1737. // previous props haven't had the chance to be set yet; set them here
  1738. this.clearUnreadPropStyle(this.unreadPropStyles);
  1739. }
  1740. this.unreadPropStyles = props.styles(this.state.lastIdealStyles);
  1741. if (this.animationID == null) {
  1742. this.prevTime = _performanceNow2['default']();
  1743. this.startAnimationIfNecessary();
  1744. }
  1745. };
  1746. StaggeredMotion.prototype.componentWillUnmount = function componentWillUnmount() {
  1747. if (this.animationID != null) {
  1748. _raf2['default'].cancel(this.animationID);
  1749. this.animationID = null;
  1750. }
  1751. };
  1752. StaggeredMotion.prototype.render = function render() {
  1753. var renderedChildren = this.props.children(this.state.currentStyles);
  1754. return renderedChildren && _react2['default'].Children.only(renderedChildren);
  1755. };
  1756. return StaggeredMotion;
  1757. })(_react2['default'].Component);
  1758. exports['default'] = StaggeredMotion;
  1759. module.exports = exports['default'];
  1760. // it's possible that currentStyle's value is stale: if props is immediately
  1761. // changed from 0 to 400 to spring(0) again, the async currentStyle is still
  1762. // at 0 (didn't have time to tick and interpolate even once). If we naively
  1763. // compare currentStyle with destVal it'll be 0 === 0 (no animation, stop).
  1764. // In reality currentStyle should be 400
  1765. // after checking for unreadPropStyles != null, we manually go set the
  1766. // non-interpolating values (those that are a number, without a spring
  1767. // config)
  1768. /***/ }),
  1769. /* 21 */
  1770. /***/ (function(module, exports, __webpack_require__) {
  1771. 'use strict';
  1772. exports.__esModule = true;
  1773. var _extends = Object.assign || function (target) { for (var i = 1; i < 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; };
  1774. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  1775. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  1776. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  1777. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1778. var _mapToZero = __webpack_require__(2);
  1779. var _mapToZero2 = _interopRequireDefault(_mapToZero);
  1780. var _stripStyle = __webpack_require__(3);
  1781. var _stripStyle2 = _interopRequireDefault(_stripStyle);
  1782. var _stepper3 = __webpack_require__(4);
  1783. var _stepper4 = _interopRequireDefault(_stepper3);
  1784. var _mergeDiff = __webpack_require__(22);
  1785. var _mergeDiff2 = _interopRequireDefault(_mergeDiff);
  1786. var _performanceNow = __webpack_require__(5);
  1787. var _performanceNow2 = _interopRequireDefault(_performanceNow);
  1788. var _raf = __webpack_require__(7);
  1789. var _raf2 = _interopRequireDefault(_raf);
  1790. var _shouldStopAnimation = __webpack_require__(9);
  1791. var _shouldStopAnimation2 = _interopRequireDefault(_shouldStopAnimation);
  1792. var _react = __webpack_require__(10);
  1793. var _react2 = _interopRequireDefault(_react);
  1794. var _propTypes = __webpack_require__(11);
  1795. var _propTypes2 = _interopRequireDefault(_propTypes);
  1796. var msPerFrame = 1000 / 60;
  1797. // the children function & (potential) styles function asks as param an
  1798. // Array<TransitionPlainStyle>, where each TransitionPlainStyle is of the format
  1799. // {key: string, data?: any, style: PlainStyle}. However, the way we keep
  1800. // internal states doesn't contain such a data structure (check the state and
  1801. // TransitionMotionState). So when children function and others ask for such
  1802. // data we need to generate them on the fly by combining mergedPropsStyles and
  1803. // currentStyles/lastIdealStyles
  1804. function rehydrateStyles(mergedPropsStyles, unreadPropStyles, plainStyles) {
  1805. // Copy the value to a `const` so that Flow understands that the const won't
  1806. // change and will be non-nullable in the callback below.
  1807. var cUnreadPropStyles = unreadPropStyles;
  1808. if (cUnreadPropStyles == null) {
  1809. return mergedPropsStyles.map(function (mergedPropsStyle, i) {
  1810. return {
  1811. key: mergedPropsStyle.key,
  1812. data: mergedPropsStyle.data,
  1813. style: plainStyles[i]
  1814. };
  1815. });
  1816. }
  1817. return mergedPropsStyles.map(function (mergedPropsStyle, i) {
  1818. for (var j = 0; j < cUnreadPropStyles.length; j++) {
  1819. if (cUnreadPropStyles[j].key === mergedPropsStyle.key) {
  1820. return {
  1821. key: cUnreadPropStyles[j].key,
  1822. data: cUnreadPropStyles[j].data,
  1823. style: plainStyles[i]
  1824. };
  1825. }
  1826. }
  1827. return { key: mergedPropsStyle.key, data: mergedPropsStyle.data, style: plainStyles[i] };
  1828. });
  1829. }
  1830. function shouldStopAnimationAll(currentStyles, destStyles, currentVelocities, mergedPropsStyles) {
  1831. if (mergedPropsStyles.length !== destStyles.length) {
  1832. return false;
  1833. }
  1834. for (var i = 0; i < mergedPropsStyles.length; i++) {
  1835. if (mergedPropsStyles[i].key !== destStyles[i].key) {
  1836. return false;
  1837. }
  1838. }
  1839. // we have the invariant that mergedPropsStyles and
  1840. // currentStyles/currentVelocities/last* are synced in terms of cells, see
  1841. // mergeAndSync comment for more info
  1842. for (var i = 0; i < mergedPropsStyles.length; i++) {
  1843. if (!_shouldStopAnimation2['default'](currentStyles[i], destStyles[i].style, currentVelocities[i])) {
  1844. return false;
  1845. }
  1846. }
  1847. return true;
  1848. }
  1849. // core key merging logic
  1850. // things to do: say previously merged style is {a, b}, dest style (prop) is {b,
  1851. // c}, previous current (interpolating) style is {a, b}
  1852. // **invariant**: current[i] corresponds to merged[i] in terms of key
  1853. // steps:
  1854. // turn merged style into {a?, b, c}
  1855. // add c, value of c is destStyles.c
  1856. // maybe remove a, aka call willLeave(a), then merged is either {b, c} or {a, b, c}
  1857. // turn current (interpolating) style from {a, b} into {a?, b, c}
  1858. // maybe remove a
  1859. // certainly add c, value of c is willEnter(c)
  1860. // loop over merged and construct new current
  1861. // dest doesn't change, that's owner's
  1862. function mergeAndSync(willEnter, willLeave, didLeave, oldMergedPropsStyles, destStyles, oldCurrentStyles, oldCurrentVelocities, oldLastIdealStyles, oldLastIdealVelocities) {
  1863. var newMergedPropsStyles = _mergeDiff2['default'](oldMergedPropsStyles, destStyles, function (oldIndex, oldMergedPropsStyle) {
  1864. var leavingStyle = willLeave(oldMergedPropsStyle);
  1865. if (leavingStyle == null) {
  1866. didLeave({ key: oldMergedPropsStyle.key, data: oldMergedPropsStyle.data });
  1867. return null;
  1868. }
  1869. if (_shouldStopAnimation2['default'](oldCurrentStyles[oldIndex], leavingStyle, oldCurrentVelocities[oldIndex])) {
  1870. didLeave({ key: oldMergedPropsStyle.key, data: oldMergedPropsStyle.data });
  1871. return null;
  1872. }
  1873. return { key: oldMergedPropsStyle.key, data: oldMergedPropsStyle.data, style: leavingStyle };
  1874. });
  1875. var newCurrentStyles = [];
  1876. var newCurrentVelocities = [];
  1877. var newLastIdealStyles = [];
  1878. var newLastIdealVelocities = [];
  1879. for (var i = 0; i < newMergedPropsStyles.length; i++) {
  1880. var newMergedPropsStyleCell = newMergedPropsStyles[i];
  1881. var foundOldIndex = null;
  1882. for (var j = 0; j < oldMergedPropsStyles.length; j++) {
  1883. if (oldMergedPropsStyles[j].key === newMergedPropsStyleCell.key) {
  1884. foundOldIndex = j;
  1885. break;
  1886. }
  1887. }
  1888. // TODO: key search code
  1889. if (foundOldIndex == null) {
  1890. var plainStyle = willEnter(newMergedPropsStyleCell);
  1891. newCurrentStyles[i] = plainStyle;
  1892. newLastIdealStyles[i] = plainStyle;
  1893. var velocity = _mapToZero2['default'](newMergedPropsStyleCell.style);
  1894. newCurrentVelocities[i] = velocity;
  1895. newLastIdealVelocities[i] = velocity;
  1896. } else {
  1897. newCurrentStyles[i] = oldCurrentStyles[foundOldIndex];
  1898. newLastIdealStyles[i] = oldLastIdealStyles[foundOldIndex];
  1899. newCurrentVelocities[i] = oldCurrentVelocities[foundOldIndex];
  1900. newLastIdealVelocities[i] = oldLastIdealVelocities[foundOldIndex];
  1901. }
  1902. }
  1903. return [newMergedPropsStyles, newCurrentStyles, newCurrentVelocities, newLastIdealStyles, newLastIdealVelocities];
  1904. }
  1905. var TransitionMotion = (function (_React$Component) {
  1906. _inherits(TransitionMotion, _React$Component);
  1907. _createClass(TransitionMotion, null, [{
  1908. key: 'propTypes',
  1909. value: {
  1910. defaultStyles: _propTypes2['default'].arrayOf(_propTypes2['default'].shape({
  1911. key: _propTypes2['default'].string.isRequired,
  1912. data: _propTypes2['default'].any,
  1913. style: _propTypes2['default'].objectOf(_propTypes2['default'].number).isRequired
  1914. })),
  1915. styles: _propTypes2['default'].oneOfType([_propTypes2['default'].func, _propTypes2['default'].arrayOf(_propTypes2['default'].shape({
  1916. key: _propTypes2['default'].string.isRequired,
  1917. data: _propTypes2['default'].any,
  1918. style: _propTypes2['default'].objectOf(_propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].object])).isRequired
  1919. }))]).isRequired,
  1920. children: _propTypes2['default'].func.isRequired,
  1921. willEnter: _propTypes2['default'].func,
  1922. willLeave: _propTypes2['default'].func,
  1923. didLeave: _propTypes2['default'].func
  1924. },
  1925. enumerable: true
  1926. }, {
  1927. key: 'defaultProps',
  1928. value: {
  1929. willEnter: function willEnter(styleThatEntered) {
  1930. return _stripStyle2['default'](styleThatEntered.style);
  1931. },
  1932. // recall: returning null makes the current unmounting TransitionStyle
  1933. // disappear immediately
  1934. willLeave: function willLeave() {
  1935. return null;
  1936. },
  1937. didLeave: function didLeave() {}
  1938. },
  1939. enumerable: true
  1940. }]);
  1941. function TransitionMotion(props) {
  1942. var _this = this;
  1943. _classCallCheck(this, TransitionMotion);
  1944. _React$Component.call(this, props);
  1945. this.unmounting = false;
  1946. this.animationID = null;
  1947. this.prevTime = 0;
  1948. this.accumulatedTime = 0;
  1949. this.unreadPropStyles = null;
  1950. this.clearUnreadPropStyle = function (unreadPropStyles) {
  1951. var _mergeAndSync = mergeAndSync(_this.props.willEnter, _this.props.willLeave, _this.props.didLeave, _this.state.mergedPropsStyles, unreadPropStyles, _this.state.currentStyles, _this.state.currentVelocities, _this.state.lastIdealStyles, _this.state.lastIdealVelocities);
  1952. var mergedPropsStyles = _mergeAndSync[0];
  1953. var currentStyles = _mergeAndSync[1];
  1954. var currentVelocities = _mergeAndSync[2];
  1955. var lastIdealStyles = _mergeAndSync[3];
  1956. var lastIdealVelocities = _mergeAndSync[4];
  1957. for (var i = 0; i < unreadPropStyles.length; i++) {
  1958. var unreadPropStyle = unreadPropStyles[i].style;
  1959. var dirty = false;
  1960. for (var key in unreadPropStyle) {
  1961. if (!Object.prototype.hasOwnProperty.call(unreadPropStyle, key)) {
  1962. continue;
  1963. }
  1964. var styleValue = unreadPropStyle[key];
  1965. if (typeof styleValue === 'number') {
  1966. if (!dirty) {
  1967. dirty = true;
  1968. currentStyles[i] = _extends({}, currentStyles[i]);
  1969. currentVelocities[i] = _extends({}, currentVelocities[i]);
  1970. lastIdealStyles[i] = _extends({}, lastIdealStyles[i]);
  1971. lastIdealVelocities[i] = _extends({}, lastIdealVelocities[i]);
  1972. mergedPropsStyles[i] = {
  1973. key: mergedPropsStyles[i].key,
  1974. data: mergedPropsStyles[i].data,
  1975. style: _extends({}, mergedPropsStyles[i].style)
  1976. };
  1977. }
  1978. currentStyles[i][key] = styleValue;
  1979. currentVelocities[i][key] = 0;
  1980. lastIdealStyles[i][key] = styleValue;
  1981. lastIdealVelocities[i][key] = 0;
  1982. mergedPropsStyles[i].style[key] = styleValue;
  1983. }
  1984. }
  1985. }
  1986. // unlike the other 2 components, we can't detect staleness and optionally
  1987. // opt out of setState here. each style object's data might contain new
  1988. // stuff we're not/cannot compare
  1989. _this.setState({
  1990. currentStyles: currentStyles,
  1991. currentVelocities: currentVelocities,
  1992. mergedPropsStyles: mergedPropsStyles,
  1993. lastIdealStyles: lastIdealStyles,
  1994. lastIdealVelocities: lastIdealVelocities
  1995. });
  1996. };
  1997. this.startAnimationIfNecessary = function () {
  1998. if (_this.unmounting) {
  1999. return;
  2000. }
  2001. // TODO: when config is {a: 10} and dest is {a: 10} do we raf once and
  2002. // call cb? No, otherwise accidental parent rerender causes cb trigger
  2003. _this.animationID = _raf2['default'](function (timestamp) {
  2004. // https://github.com/chenglou/react-motion/pull/420
  2005. // > if execution passes the conditional if (this.unmounting), then
  2006. // executes async defaultRaf and after that component unmounts and after
  2007. // that the callback of defaultRaf is called, then setState will be called
  2008. // on unmounted component.
  2009. if (_this.unmounting) {
  2010. return;
  2011. }
  2012. var propStyles = _this.props.styles;
  2013. var destStyles = typeof propStyles === 'function' ? propStyles(rehydrateStyles(_this.state.mergedPropsStyles, _this.unreadPropStyles, _this.state.lastIdealStyles)) : propStyles;
  2014. // check if we need to animate in the first place
  2015. if (shouldStopAnimationAll(_this.state.currentStyles, destStyles, _this.state.currentVelocities, _this.state.mergedPropsStyles)) {
  2016. // no need to cancel animationID here; shouldn't have any in flight
  2017. _this.animationID = null;
  2018. _this.accumulatedTime = 0;
  2019. return;
  2020. }
  2021. var currentTime = timestamp || _performanceNow2['default']();
  2022. var timeDelta = currentTime - _this.prevTime;
  2023. _this.prevTime = currentTime;
  2024. _this.accumulatedTime = _this.accumulatedTime + timeDelta;
  2025. // more than 10 frames? prolly switched browser tab. Restart
  2026. if (_this.accumulatedTime > msPerFrame * 10) {
  2027. _this.accumulatedTime = 0;
  2028. }
  2029. if (_this.accumulatedTime === 0) {
  2030. // no need to cancel animationID here; shouldn't have any in flight
  2031. _this.animationID = null;
  2032. _this.startAnimationIfNecessary();
  2033. return;
  2034. }
  2035. var currentFrameCompletion = (_this.accumulatedTime - Math.floor(_this.accumulatedTime / msPerFrame) * msPerFrame) / msPerFrame;
  2036. var framesToCatchUp = Math.floor(_this.accumulatedTime / msPerFrame);
  2037. var _mergeAndSync2 = mergeAndSync(_this.props.willEnter, _this.props.willLeave, _this.props.didLeave, _this.state.mergedPropsStyles, destStyles, _this.state.currentStyles, _this.state.currentVelocities, _this.state.lastIdealStyles, _this.state.lastIdealVelocities);
  2038. var newMergedPropsStyles = _mergeAndSync2[0];
  2039. var newCurrentStyles = _mergeAndSync2[1];
  2040. var newCurrentVelocities = _mergeAndSync2[2];
  2041. var newLastIdealStyles = _mergeAndSync2[3];
  2042. var newLastIdealVelocities = _mergeAndSync2[4];
  2043. for (var i = 0; i < newMergedPropsStyles.length; i++) {
  2044. var newMergedPropsStyle = newMergedPropsStyles[i].style;
  2045. var newCurrentStyle = {};
  2046. var newCurrentVelocity = {};
  2047. var newLastIdealStyle = {};
  2048. var newLastIdealVelocity = {};
  2049. for (var key in newMergedPropsStyle) {
  2050. if (!Object.prototype.hasOwnProperty.call(newMergedPropsStyle, key)) {
  2051. continue;
  2052. }
  2053. var styleValue = newMergedPropsStyle[key];
  2054. if (typeof styleValue === 'number') {
  2055. newCurrentStyle[key] = styleValue;
  2056. newCurrentVelocity[key] = 0;
  2057. newLastIdealStyle[key] = styleValue;
  2058. newLastIdealVelocity[key] = 0;
  2059. } else {
  2060. var newLastIdealStyleValue = newLastIdealStyles[i][key];
  2061. var newLastIdealVelocityValue = newLastIdealVelocities[i][key];
  2062. for (var j = 0; j < framesToCatchUp; j++) {
  2063. var _stepper = _stepper4['default'](msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.stiffness, styleValue.damping, styleValue.precision);
  2064. newLastIdealStyleValue = _stepper[0];
  2065. newLastIdealVelocityValue = _stepper[1];
  2066. }
  2067. var _stepper2 = _stepper4['default'](msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.stiffness, styleValue.damping, styleValue.precision);
  2068. var nextIdealX = _stepper2[0];
  2069. var nextIdealV = _stepper2[1];
  2070. newCurrentStyle[key] = newLastIdealStyleValue + (nextIdealX - newLastIdealStyleValue) * currentFrameCompletion;
  2071. newCurrentVelocity[key] = newLastIdealVelocityValue + (nextIdealV - newLastIdealVelocityValue) * currentFrameCompletion;
  2072. newLastIdealStyle[key] = newLastIdealStyleValue;
  2073. newLastIdealVelocity[key] = newLastIdealVelocityValue;
  2074. }
  2075. }
  2076. newLastIdealStyles[i] = newLastIdealStyle;
  2077. newLastIdealVelocities[i] = newLastIdealVelocity;
  2078. newCurrentStyles[i] = newCurrentStyle;
  2079. newCurrentVelocities[i] = newCurrentVelocity;
  2080. }
  2081. _this.animationID = null;
  2082. // the amount we're looped over above
  2083. _this.accumulatedTime -= framesToCatchUp * msPerFrame;
  2084. _this.setState({
  2085. currentStyles: newCurrentStyles,
  2086. currentVelocities: newCurrentVelocities,
  2087. lastIdealStyles: newLastIdealStyles,
  2088. lastIdealVelocities: newLastIdealVelocities,
  2089. mergedPropsStyles: newMergedPropsStyles
  2090. });
  2091. _this.unreadPropStyles = null;
  2092. _this.startAnimationIfNecessary();
  2093. });
  2094. };
  2095. this.state = this.defaultState();
  2096. }
  2097. TransitionMotion.prototype.defaultState = function defaultState() {
  2098. var _props = this.props;
  2099. var defaultStyles = _props.defaultStyles;
  2100. var styles = _props.styles;
  2101. var willEnter = _props.willEnter;
  2102. var willLeave = _props.willLeave;
  2103. var didLeave = _props.didLeave;
  2104. var destStyles = typeof styles === 'function' ? styles(defaultStyles) : styles;
  2105. // this is special. for the first time around, we don't have a comparison
  2106. // between last (no last) and current merged props. we'll compute last so:
  2107. // say default is {a, b} and styles (dest style) is {b, c}, we'll
  2108. // fabricate last as {a, b}
  2109. var oldMergedPropsStyles = undefined;
  2110. if (defaultStyles == null) {
  2111. oldMergedPropsStyles = destStyles;
  2112. } else {
  2113. oldMergedPropsStyles = defaultStyles.map(function (defaultStyleCell) {
  2114. // TODO: key search code
  2115. for (var i = 0; i < destStyles.length; i++) {
  2116. if (destStyles[i].key === defaultStyleCell.key) {
  2117. return destStyles[i];
  2118. }
  2119. }
  2120. return defaultStyleCell;
  2121. });
  2122. }
  2123. var oldCurrentStyles = defaultStyles == null ? destStyles.map(function (s) {
  2124. return _stripStyle2['default'](s.style);
  2125. }) : defaultStyles.map(function (s) {
  2126. return _stripStyle2['default'](s.style);
  2127. });
  2128. var oldCurrentVelocities = defaultStyles == null ? destStyles.map(function (s) {
  2129. return _mapToZero2['default'](s.style);
  2130. }) : defaultStyles.map(function (s) {
  2131. return _mapToZero2['default'](s.style);
  2132. });
  2133. var _mergeAndSync3 = mergeAndSync(
  2134. // Because this is an old-style createReactClass component, Flow doesn't
  2135. // understand that the willEnter and willLeave props have default values
  2136. // and will always be present.
  2137. willEnter, willLeave, didLeave, oldMergedPropsStyles, destStyles, oldCurrentStyles, oldCurrentVelocities, oldCurrentStyles, // oldLastIdealStyles really
  2138. oldCurrentVelocities);
  2139. var mergedPropsStyles = _mergeAndSync3[0];
  2140. var currentStyles = _mergeAndSync3[1];
  2141. var currentVelocities = _mergeAndSync3[2];
  2142. var lastIdealStyles = _mergeAndSync3[3];
  2143. var lastIdealVelocities = _mergeAndSync3[4];
  2144. // oldLastIdealVelocities really
  2145. return {
  2146. currentStyles: currentStyles,
  2147. currentVelocities: currentVelocities,
  2148. lastIdealStyles: lastIdealStyles,
  2149. lastIdealVelocities: lastIdealVelocities,
  2150. mergedPropsStyles: mergedPropsStyles
  2151. };
  2152. };
  2153. // after checking for unreadPropStyles != null, we manually go set the
  2154. // non-interpolating values (those that are a number, without a spring
  2155. // config)
  2156. TransitionMotion.prototype.componentDidMount = function componentDidMount() {
  2157. this.prevTime = _performanceNow2['default']();
  2158. this.startAnimationIfNecessary();
  2159. };
  2160. TransitionMotion.prototype.componentWillReceiveProps = function componentWillReceiveProps(props) {
  2161. if (this.unreadPropStyles) {
  2162. // previous props haven't had the chance to be set yet; set them here
  2163. this.clearUnreadPropStyle(this.unreadPropStyles);
  2164. }
  2165. var styles = props.styles;
  2166. if (typeof styles === 'function') {
  2167. this.unreadPropStyles = styles(rehydrateStyles(this.state.mergedPropsStyles, this.unreadPropStyles, this.state.lastIdealStyles));
  2168. } else {
  2169. this.unreadPropStyles = styles;
  2170. }
  2171. if (this.animationID == null) {
  2172. this.prevTime = _performanceNow2['default']();
  2173. this.startAnimationIfNecessary();
  2174. }
  2175. };
  2176. TransitionMotion.prototype.componentWillUnmount = function componentWillUnmount() {
  2177. this.unmounting = true;
  2178. if (this.animationID != null) {
  2179. _raf2['default'].cancel(this.animationID);
  2180. this.animationID = null;
  2181. }
  2182. };
  2183. TransitionMotion.prototype.render = function render() {
  2184. var hydratedStyles = rehydrateStyles(this.state.mergedPropsStyles, this.unreadPropStyles, this.state.currentStyles);
  2185. var renderedChildren = this.props.children(hydratedStyles);
  2186. return renderedChildren && _react2['default'].Children.only(renderedChildren);
  2187. };
  2188. return TransitionMotion;
  2189. })(_react2['default'].Component);
  2190. exports['default'] = TransitionMotion;
  2191. module.exports = exports['default'];
  2192. // list of styles, each containing interpolating values. Part of what's passed
  2193. // to children function. Notice that this is
  2194. // Array<ActualInterpolatingStyleObject>, without the wrapper that is {key: ...,
  2195. // data: ... style: ActualInterpolatingStyleObject}. Only mergedPropsStyles
  2196. // contains the key & data info (so that we only have a single source of truth
  2197. // for these, and to save space). Check the comment for `rehydrateStyles` to
  2198. // see how we regenerate the entirety of what's passed to children function
  2199. // the array that keeps track of currently rendered stuff! Including stuff
  2200. // that you've unmounted but that's still animating. This is where it lives
  2201. // it's possible that currentStyle's value is stale: if props is immediately
  2202. // changed from 0 to 400 to spring(0) again, the async currentStyle is still
  2203. // at 0 (didn't have time to tick and interpolate even once). If we naively
  2204. // compare currentStyle with destVal it'll be 0 === 0 (no animation, stop).
  2205. // In reality currentStyle should be 400
  2206. /***/ }),
  2207. /* 22 */
  2208. /***/ (function(module, exports) {
  2209. // core keys merging algorithm. If previous render's keys are [a, b], and the
  2210. // next render's [c, b, d], what's the final merged keys and ordering?
  2211. // - c and a must both be before b
  2212. // - b before d
  2213. // - ordering between a and c ambiguous
  2214. // this reduces to merging two partially ordered lists (e.g. lists where not
  2215. // every item has a definite ordering, like comparing a and c above). For the
  2216. // ambiguous ordering we deterministically choose to place the next render's
  2217. // item after the previous'; so c after a
  2218. // this is called a topological sorting. Except the existing algorithms don't
  2219. // work well with js bc of the amount of allocation, and isn't optimized for our
  2220. // current use-case bc the runtime is linear in terms of edges (see wiki for
  2221. // meaning), which is huge when two lists have many common elements
  2222. 'use strict';
  2223. exports.__esModule = true;
  2224. exports['default'] = mergeDiff;
  2225. function mergeDiff(prev, next, onRemove) {
  2226. // bookkeeping for easier access of a key's index below. This is 2 allocations +
  2227. // potentially triggering chrome hash map mode for objs (so it might be faster
  2228. var prevKeyIndex = {};
  2229. for (var i = 0; i < prev.length; i++) {
  2230. prevKeyIndex[prev[i].key] = i;
  2231. }
  2232. var nextKeyIndex = {};
  2233. for (var i = 0; i < next.length; i++) {
  2234. nextKeyIndex[next[i].key] = i;
  2235. }
  2236. // first, an overly elaborate way of merging prev and next, eliminating
  2237. // duplicates (in terms of keys). If there's dupe, keep the item in next).
  2238. // This way of writing it saves allocations
  2239. var ret = [];
  2240. for (var i = 0; i < next.length; i++) {
  2241. ret[i] = next[i];
  2242. }
  2243. for (var i = 0; i < prev.length; i++) {
  2244. if (!Object.prototype.hasOwnProperty.call(nextKeyIndex, prev[i].key)) {
  2245. // this is called my TM's `mergeAndSync`, which calls willLeave. We don't
  2246. // merge in keys that the user desires to kill
  2247. var fill = onRemove(i, prev[i]);
  2248. if (fill != null) {
  2249. ret.push(fill);
  2250. }
  2251. }
  2252. }
  2253. // now all the items all present. Core sorting logic to have the right order
  2254. return ret.sort(function (a, b) {
  2255. var nextOrderA = nextKeyIndex[a.key];
  2256. var nextOrderB = nextKeyIndex[b.key];
  2257. var prevOrderA = prevKeyIndex[a.key];
  2258. var prevOrderB = prevKeyIndex[b.key];
  2259. if (nextOrderA != null && nextOrderB != null) {
  2260. // both keys in next
  2261. return nextKeyIndex[a.key] - nextKeyIndex[b.key];
  2262. } else if (prevOrderA != null && prevOrderB != null) {
  2263. // both keys in prev
  2264. return prevKeyIndex[a.key] - prevKeyIndex[b.key];
  2265. } else if (nextOrderA != null) {
  2266. // key a in next, key b in prev
  2267. // how to determine the order between a and b? We find a "pivot" (term
  2268. // abuse), a key present in both prev and next, that is sandwiched between
  2269. // a and b. In the context of our above example, if we're comparing a and
  2270. // d, b's (the only) pivot
  2271. for (var i = 0; i < next.length; i++) {
  2272. var pivot = next[i].key;
  2273. if (!Object.prototype.hasOwnProperty.call(prevKeyIndex, pivot)) {
  2274. continue;
  2275. }
  2276. if (nextOrderA < nextKeyIndex[pivot] && prevOrderB > prevKeyIndex[pivot]) {
  2277. return -1;
  2278. } else if (nextOrderA > nextKeyIndex[pivot] && prevOrderB < prevKeyIndex[pivot]) {
  2279. return 1;
  2280. }
  2281. }
  2282. // pluggable. default to: next bigger than prev
  2283. return 1;
  2284. }
  2285. // prevOrderA, nextOrderB
  2286. for (var i = 0; i < next.length; i++) {
  2287. var pivot = next[i].key;
  2288. if (!Object.prototype.hasOwnProperty.call(prevKeyIndex, pivot)) {
  2289. continue;
  2290. }
  2291. if (nextOrderB < nextKeyIndex[pivot] && prevOrderA > prevKeyIndex[pivot]) {
  2292. return 1;
  2293. } else if (nextOrderB > nextKeyIndex[pivot] && prevOrderA < prevKeyIndex[pivot]) {
  2294. return -1;
  2295. }
  2296. }
  2297. // pluggable. default to: next bigger than prev
  2298. return -1;
  2299. });
  2300. }
  2301. module.exports = exports['default'];
  2302. // to loop through and find a key's index each time), but I no longer care
  2303. /***/ }),
  2304. /* 23 */
  2305. /***/ (function(module, exports, __webpack_require__) {
  2306. 'use strict';
  2307. exports.__esModule = true;
  2308. var _extends = Object.assign || function (target) { for (var i = 1; i < 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; };
  2309. exports['default'] = spring;
  2310. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2311. var _presets = __webpack_require__(24);
  2312. var _presets2 = _interopRequireDefault(_presets);
  2313. var defaultConfig = _extends({}, _presets2['default'].noWobble, {
  2314. precision: 0.01
  2315. });
  2316. function spring(val, config) {
  2317. return _extends({}, defaultConfig, config, { val: val });
  2318. }
  2319. module.exports = exports['default'];
  2320. /***/ }),
  2321. /* 24 */
  2322. /***/ (function(module, exports) {
  2323. "use strict";
  2324. exports.__esModule = true;
  2325. exports["default"] = {
  2326. noWobble: { stiffness: 170, damping: 26 }, // the default, if nothing provided
  2327. gentle: { stiffness: 120, damping: 14 },
  2328. wobbly: { stiffness: 180, damping: 12 },
  2329. stiff: { stiffness: 210, damping: 20 }
  2330. };
  2331. module.exports = exports["default"];
  2332. /***/ }),
  2333. /* 25 */
  2334. /***/ (function(module, exports, __webpack_require__) {
  2335. /* WEBPACK VAR INJECTION */(function(process) {'use strict';
  2336. exports.__esModule = true;
  2337. exports['default'] = reorderKeys;
  2338. var hasWarned = false;
  2339. function reorderKeys() {
  2340. if (process.env.NODE_ENV === 'development') {
  2341. if (!hasWarned) {
  2342. hasWarned = true;
  2343. console.error('`reorderKeys` has been removed, since it is no longer needed for TransitionMotion\'s new styles array API.');
  2344. }
  2345. }
  2346. }
  2347. module.exports = exports['default'];
  2348. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
  2349. /***/ })
  2350. /******/ ])
  2351. });
  2352. ;
  2353. //# sourceMappingURL=react-motion.map