kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
231 lines (185 loc) • 24.2 kB
JavaScript
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
var _react = _interopRequireWildcard(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _moment = _interopRequireDefault(require("moment"));
var _window = require("global/window");
var _slider = _interopRequireDefault(require("../slider/slider"));
var _styledComponents2 = require("../styled-components");
var _speedControl = _interopRequireDefault(require("./speed-control"));
var _playbackControls = _interopRequireDefault(require("./playback-controls"));
var _floatingTimeDisplay = _interopRequireDefault(require("./floating-time-display"));
var _defaultSettings = require("../../../constants/default-settings");
function _templateObject3() {
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-weight: 400;\n font-size: 10px;\n"]);
_templateObject3 = function _templateObject3() {
return data;
};
return data;
}
function _templateObject2() {
var data = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n display: flex;\n align-items: center;\n height: 32px;\n\n .animation-control__speed-control {\n margin-right: -10px;\n\n .animation-control__speed-slider {\n right: calc(0% - 10px);\n }\n }\n"]);
_templateObject2 = function _templateObject2() {
return data;
};
return data;
}
function _templateObject() {
var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n position: relative;\n flex-grow: 1;\n margin-right: 24px;\n margin-left: 24px;\n"]);
_templateObject = function _templateObject() {
return data;
};
return data;
}
var SliderWrapper = _styledComponents["default"].div(_templateObject());
var AnimationWidgetInner = _styledComponents["default"].div(_templateObject2());
var StyledDomain = _styledComponents["default"].div(_templateObject3(), function (props) {
return props.theme.titleTextColor;
});
var defaultTimeFormat = 'MM/DD/YY hh:mm:ss';
var BUTTON_HEIGHT = '18px';
AnimationControlFactory.deps = [_speedControl["default"], _playbackControls["default"], _floatingTimeDisplay["default"]];
function AnimationControlFactory(SpeedControl, AnimationPlaybacks, FloatingTimeDisplay) {
var AnimationControl =
/*#__PURE__*/
function (_Component) {
(0, _inherits2["default"])(AnimationControl, _Component);
function AnimationControl(props) {
var _this;
(0, _classCallCheck2["default"])(this, AnimationControl);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(AnimationControl).call(this, props));
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSlider1Change", function (val) {
var domain = _this.props.animationConfig.domain;
if (val >= domain[0] && val <= domain[1]) {
_this.props.updateAnimationTime(val);
}
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_updateAnimationTime", function () {
var domain = _this.props.animationConfig.domain;
_this.props.updateAnimationTime(domain[0]);
_this._startAnimation();
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_startAnimation", function () {
_this._pauseAnimation();
_this.setState({
isAnimating: true
});
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_nextFrame", function () {
_this._animation = null;
var _this$props$animation = _this.props.animationConfig,
currentTime = _this$props$animation.currentTime,
domain = _this$props$animation.domain,
_this$props$animation2 = _this$props$animation.speed,
speed = _this$props$animation2 === void 0 ? 1 : _this$props$animation2;
var adjustedSpeed = (domain[1] - domain[0]) / _defaultSettings.BASE_SPEED * speed;
var nextTime = currentTime + speed > domain[1] ? domain[0] : currentTime + adjustedSpeed;
_this.props.updateAnimationTime(nextTime);
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_pauseAnimation", function () {
if (_this._animation) {
(0, _window.cancelAnimationFrame)(_this._animation);
_this._animation = null;
}
_this.setState({
isAnimating: false
});
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "toggleSpeedControl", function () {
_this.setState({
showSpeedControl: !_this.state.showSpeedControl
});
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function () {
_this.toggleSpeedControl();
});
_this.state = {
isAnimating: false,
width: 288,
showSpeedControl: false
};
_this._animation = null;
return _this;
}
(0, _createClass2["default"])(AnimationControl, [{
key: "componentDidUpdate",
value: function componentDidUpdate() {
if (!this._animation && this.state.isAnimating) {
this._animation = (0, _window.requestAnimationFrame)(this._nextFrame);
}
}
}, {
key: "render",
value: function render() {
var _this$props$animation3 = this.props.animationConfig,
currentTime = _this$props$animation3.currentTime,
domain = _this$props$animation3.domain,
speed = _this$props$animation3.speed;
var showSpeedControl = this.state.showSpeedControl;
return _react["default"].createElement(_styledComponents2.BottomWidgetInner, {
className: "bottom-widget--inner"
}, _react["default"].createElement(AnimationWidgetInner, {
className: "animation-widget--inner"
}, _react["default"].createElement("div", {
style: {
marginLeft: '-10px'
}
}, _react["default"].createElement(AnimationPlaybacks, {
className: "animation-control-playpause",
startAnimation: this._startAnimation,
isAnimating: this.state.isAnimating,
pauseAnimation: this._pauseAnimation,
resetAnimation: this._resetAnimation,
buttonHeight: BUTTON_HEIGHT,
buttonStyle: "link"
})), _react["default"].createElement(StyledDomain, {
className: "animation-control__time-domain"
}, _react["default"].createElement("span", null, _moment["default"].utc(domain[0]).format(defaultTimeFormat))), _react["default"].createElement(SliderWrapper, {
className: "animation-control__slider"
}, _react["default"].createElement(_slider["default"], {
showValues: false,
isRanged: false,
minValue: domain ? domain[0] : 0,
maxValue: domain ? domain[1] : 1,
value1: currentTime,
onSlider1Change: this.onSlider1Change,
enableBarDrag: true
})), _react["default"].createElement(StyledDomain, {
className: "animation-control__time-domain"
}, _react["default"].createElement("span", null, _moment["default"].utc(domain[1]).format(defaultTimeFormat))), _react["default"].createElement("div", {
className: "animation-control__speed-control"
}, _react["default"].createElement(SpeedControl, {
onClick: this.toggleSpeedControl,
showSpeedControl: showSpeedControl,
updateAnimationSpeed: this.props.updateAnimationSpeed,
speed: speed,
buttonHeight: BUTTON_HEIGHT
}))), _react["default"].createElement(FloatingTimeDisplay, {
currentTime: currentTime
}));
}
}]);
return AnimationControl;
}(_react.Component);
AnimationControl.defaultProps = {
sliderHandleWidth: 12,
onChange: function onChange() {}
};
return AnimationControl;
}
var _default = AnimationControlFactory;
exports["default"] = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL2NvbW1vbi9hbmltYXRpb24tY29udHJvbC9hbmltYXRpb24tY29udHJvbC5qcyJdLCJuYW1lcyI6WyJTbGlkZXJXcmFwcGVyIiwic3R5bGVkIiwiZGl2IiwiQW5pbWF0aW9uV2lkZ2V0SW5uZXIiLCJTdHlsZWREb21haW4iLCJwcm9wcyIsInRoZW1lIiwidGl0bGVUZXh0Q29sb3IiLCJkZWZhdWx0VGltZUZvcm1hdCIsIkJVVFRPTl9IRUlHSFQiLCJBbmltYXRpb25Db250cm9sRmFjdG9yeSIsImRlcHMiLCJTcGVlZENvbnRyb2xGYWN0b3J5IiwiQW5pbWF0aW9uUGxheWJhY2tzRmFjdG9yeSIsIkZsb2F0aW5nVGltZURpc3BsYXlGYWN0b3J5IiwiU3BlZWRDb250cm9sIiwiQW5pbWF0aW9uUGxheWJhY2tzIiwiRmxvYXRpbmdUaW1lRGlzcGxheSIsIkFuaW1hdGlvbkNvbnRyb2wiLCJ2YWwiLCJkb21haW4iL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jbGFzc05hbWU9XCJhbmltYXRpb24td2lkZ2V0LS1pbm5lclwiPlxuICAgICAgICAgICAgPGRpdiBzdHlsZT17e21hcmdpbkxlZnQ6ICctMTBweCd9fT5cbiAgICAgICAgICAgICAgPEFuaW1hdGlvblBsYXliYWNrc1xuICAgICAgICAgICAgICAgIGNsYXNzTmFtZT1cImFuaW1hdGlvbi1jb250cm9sLXBsYXlwYXVzZVwiXG4gICAgICAgICAgICAgICAgc3RhcnRBbmltYXRpb249e3RoaXMuX3N0YXJ0QW5pbWF0aW9ufVxuICAgICAgICAgICAgICAgIGlzQW5pbWF0aW5nPXt0aGlzLnN0YXRlLmlzQW5pbWF0aW5nfVxuICAgICAgICAgICAgICAgIHBhdXNlQW5pbWF0aW9uPXt0aGlzLl9wYXVzZUFuaW1hdGlvbn1cbiAgICAgICAgICAgICAgICByZXNldEFuaW1hdGlvbj17dGhpcy5fcmVzZXRBbmltYXRpb259XG4gICAgICAgICAgICAgICAgYnV0dG9uSGVpZ2h0PXtCVVRUT05fSEVJR0hUfVxuICAgICAgICAgICAgICAgIGJ1dHRvblN0eWxlPVwibGlua1wiXG4gICAgICAgICAgICAgIC8+XG4gICAgICAgICAgICA8L2Rpdj5cbiAgICAgICAgICAgIDxTdHlsZWREb21haW4gY2xhc3NOYW1lPVwiYW5pbWF0aW9uLWNvbnRyb2xfX3RpbWUtZG9tYWluXCI+XG4gICAgICAgICAgICAgIDxzcGFuPnttb21lbnQudXRjKGRvbWFpblswXSkuZm9ybWF0KGRlZmF1bHRUaW1lRm9ybWF0KX08L3NwYW4+XG4gICAgICAgICAgICA8L1N0eWxlZERvbWFpbj5cbiAgICAgICAgICAgIDxTbGlkZXJXcmFwcGVyIGNsYXNzTmFtZT1cImFuaW1hdGlvbi1jb250cm9sX19zbGlkZXJcIj5cbiAgICAgICAgICAgICAgPFNsaWRlclxuICAgICAgICAgICAgICAgIHNob3dWYWx1ZXM9e2ZhbHNlfVxuICAgICAgICAgICAgICAgIGlzUmFuZ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