UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

54 lines (51 loc) 11 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _constants = require("@kepler.gl/constants"); var _utils = require("@kepler.gl/utils"); var _commonUtils = require("@kepler.gl/common-utils"); var _animationController = _interopRequireDefault(require("./common/animation-control/animation-controller")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project LayerAnimationControllerFactory.deps = [_animationController["default"]]; function LayerAnimationControllerFactory(AnimationController) { var LayerAnimationController = function LayerAnimationController(_ref) { var animationConfig = _ref.animationConfig, setLayerAnimationTime = _ref.setLayerAnimationTime, children = _ref.children; var timeSteps = animationConfig.timeSteps, domain = animationConfig.domain; var setTimelineValue = (0, _react.useCallback)(function (value) { var timelineValue = (0, _commonUtils.toArray)(value)[0]; if (Array.isArray(timeSteps)) { setLayerAnimationTime((0, _utils.snapToMarks)(timelineValue, timeSteps)); // TODO: merge slider in to avoid this step } else if (domain && timelineValue >= domain[0] && timelineValue <= domain[1]) { setLayerAnimationTime(timelineValue); } }, [domain, setLayerAnimationTime, timeSteps]); var timeline = (0, _utils.getTimelineFromAnimationConfig)(animationConfig); return /*#__PURE__*/_react["default"].createElement(AnimationController, { key: "layer-control", value: Number(animationConfig.currentTime), domain: animationConfig.domain, speed: animationConfig.speed, isAnimating: animationConfig.isAnimating, steps: animationConfig.timeSteps, animationWindow: animationConfig.timeSteps ? _constants.ANIMATION_WINDOW.interval : _constants.ANIMATION_WINDOW.point, setTimelineValue: setTimelineValue, timeline: timeline, children: children }); }; return LayerAnimationController; } var _default = exports["default"] = LayerAnimationControllerFactory; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfY29uc3RhbnRzIiwiX3V0aWxzIiwiX2NvbW1vblV0aWxzIiwiX2FuaW1hdGlvbkNvbnRyb2xsZXIiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwiX2dldFJlcXVpcmVXaWxkY2FyZENhY2hlIiwiZSIsIldlYWtNYXAiLCJyIiwidCIsIl9fZXNNb2R1bGUiLCJfdHlwZW9mIiwiaGFzIiwiZ2V0IiwibiIsIl9fcHJvdG9fXyIsImEiLCJPYmplY3QiLCJkZWZpbmVQcm9wZXJ0eSIsImdldE93blByb3BlcnR5RGVzY3JpcHRvciIsInUiLCJoYXNPd25Qcm9wZXJ0eSIsImNhbGwiLCJpIiwic2V0IiwiTGF5ZXJBbmltYXRpb25Db250cm9sbGVyRmFjdG9yeSIsImRlcHMiLCJBbmltYXRpb25Db250cm9sbGVyRmFjdG9yeSIsIkFuaW1hdGlvbkNvbnRyb2xsZXIiLCJMYXllckFuaW1hdGlvbkNvbnRyb2xsZXIiLCJfcmVmIiwiYW5pbWF0aW9uQ29uZmlnIiwic2V0TGF5ZXJBbmltYXRpb25UaW1lIiwiY2hpbGRyZW4iLCJ0aW1lU3RlcHMiLCJkb21haW4iLCJzZXRUaW1lbGlu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