GoScrobble/web/node_modules/.cache/babel-loader/469343915a1433294fe1cd451343d986.json

1 line
32 KiB
JSON
Raw Normal View History

2022-04-25 02:47:15 +00:00
{"ast":null,"code":"import _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport CarouselItem from './CarouselItem';\nimport { mapToCssModules } from './utils';\nvar SWIPE_THRESHOLD = 40;\n\nvar Carousel = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(Carousel, _React$Component);\n\n function Carousel(props) {\n var _this;\n\n _this = _React$Component.call(this, props) || this;\n _this.handleKeyPress = _this.handleKeyPress.bind(_assertThisInitialized(_this));\n _this.renderItems = _this.renderItems.bind(_assertThisInitialized(_this));\n _this.hoverStart = _this.hoverStart.bind(_assertThisInitialized(_this));\n _this.hoverEnd = _this.hoverEnd.bind(_assertThisInitialized(_this));\n _this.handleTouchStart = _this.handleTouchStart.bind(_assertThisInitialized(_this));\n _this.handleTouchEnd = _this.handleTouchEnd.bind(_assertThisInitialized(_this));\n _this.touchStartX = 0;\n _this.touchStartY = 0;\n _this.state = {\n activeIndex: _this.props.activeIndex,\n direction: 'right',\n indicatorClicked: false\n };\n return _this;\n }\n\n var _proto = Carousel.prototype;\n\n _proto.getChildContext = function getChildContext() {\n return {\n direction: this.state.direction\n };\n };\n\n _proto.componentDidMount = function componentDidMount() {\n // Set up the cycle\n if (this.props.ride === 'carousel') {\n this.setInterval();\n } // TODO: move this to the specific carousel like bootstrap. Currently it will trigger ALL carousels on the page.\n\n\n document.addEventListener('keyup', this.handleKeyPress);\n };\n\n Carousel.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {\n var newState = null;\n var activeIndex = prevState.activeIndex,\n direction = prevState.direction,\n indicatorClicked = prevState.indicatorClicked;\n\n if (nextProps.activeIndex !== activeIndex) {\n // Calculate the direction to turn\n if (nextProps.activeIndex === activeIndex + 1) {\n direction = 'right';\n } else if (nextProps.activeIndex === activeIndex - 1) {\n direction = 'left';\n } else if (nextProps.activeIndex < activeIndex) {\n direction = indicatorClicked ? 'left' : 'right';\n } else if (nextProps.activeIndex !== activeIndex) {\n direction = indicatorClicked ? 'right' : 'left';\n }\n\n newState = {\n activeIndex: nextProps.activeIndex,\n direction: direction,\n indicatorClicked: false\n };\n }\n\n return newState;\n };\n\n _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {\n if (prevState.activeIndex === this.state.activeIndex) return;\n this.setInterval(this.props);\n };\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n this.clearInterval();\n document.removeEventListener('keyup', this.handleKeyPress);\n };\n\n _proto.setInterval = function (_setInterval) {\n function setInterval() {\n return _setInterval.apply(this, arguments);\n }\n\n setInterval.toString = function () {\n return _setInterval.toString();\n };\n\n return setInterval;\n }(function (props) {\n if (props === void 0) {\n props = this.props;\n } // make sure not to have multiple intervals going...\n\n\n this.clearInterval();\n\n if (props.interval) {\n this.cycleInterval = setInterval(function () {\n props.next();\n }, parseInt(props.interval, 10));\n }\n });\n\n _proto.clearInterval = function (_clearInterval) {\n function clearInterval() {\n return _clearInterval.apply(this, arguments);\n }\n\n clearInterval.toString = function () {\n return _clearInterval.toString();\n };\n\n return clearInterval;\n }(function () {\n clearInterval(this.cycleInterval);\n });\n\n _proto