@momo-kits/carousel 0.0.34-beta → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1 +1,7 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Carousel",{enumerable:true,get:function get(){return _Carousel.default;}});Object.defineProperty(exports,"Pagination",{enumerable:true,get:function get(){return _Pagination.default;}});var _Carousel=_interopRequireDefault(require("./Carousel"));var _Pagination=_interopRequireDefault(require("./pagination/Pagination"));
1
+ //import Carousel from './Carousel';
2
+ import Carousel from './CarouselV2';
3
+ import Pagination from './pagination/Pagination';
4
+
5
+ export {
6
+ Carousel, Pagination
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/carousel",
3
- "version": "0.0.34-beta",
3
+ "version": "0.0.34",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -11,13 +11,6 @@
11
11
  "react": "16.9.0",
12
12
  "react-native": ">=0.55"
13
13
  },
14
- "devDependencies": {
15
- "metro-react-native-babel-preset": "^0.64.0",
16
- "@babel/core": "^7.12.9",
17
- "@babel/runtime": "^7.12.5"
18
- },
19
- "license": "MoMo",
20
- "jest": {
21
- "preset": "react-native"
22
- }
14
+ "devDependencies": {},
15
+ "license": "MoMo"
23
16
  }
@@ -1 +1,158 @@
1
- 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 _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _PaginationDot=_interopRequireDefault(require("./PaginationDot"));var _styles=_interopRequireDefault(require("./styles"));var _jsxFileName="/Users/trinh.ho2/momo-folk/kits/src/libs/carousel/dist/pagination/Pagination.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2.default)(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2.default)(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2.default)(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var IS_IOS=_reactNative.Platform.OS==='ios';var IS_RTL=_reactNative.I18nManager.isRTL;var Pagination=function(_PureComponent){(0,_inherits2.default)(Pagination,_PureComponent);var _super=_createSuper(Pagination);function Pagination(props){var _this;(0,_classCallCheck2.default)(this,Pagination);_this=_super.call(this,props);if(props.dotColor&&!props.inactiveDotColor||!props.dotColor&&props.inactiveDotColor){console.warn('react-native-snap-carousel | Pagination: '+'You need to specify both `dotColor` and `inactiveDotColor`');}if(props.dotElement&&!props.inactiveDotElement||!props.dotElement&&props.inactiveDotElement){console.warn('react-native-snap-carousel | Pagination: '+'You need to specify both `dotElement` and `inactiveDotElement`');}if(props.tappableDots&&!props.carouselRef){console.warn('react-native-snap-carousel | Pagination: '+'You must specify prop `carouselRef` when setting `tappableDots` to `true`');}return _this;}(0,_createClass2.default)(Pagination,[{key:"_needsRTLAdaptations",value:function _needsRTLAdaptations(){var vertical=this.props.vertical;return IS_RTL&&!IS_IOS&&!vertical;}},{key:"_activeDotIndex",get:function get(){var _this$props=this.props,activeDotIndex=_this$props.activeDotIndex,dotsLength=_this$props.dotsLength;return this._needsRTLAdaptations()?dotsLength-activeDotIndex-1:activeDotIndex;}},{key:"dots",get:function get(){var _this$props2=this.props,activeOpacity=_this$props2.activeOpacity,carouselRef=_this$props2.carouselRef,dotsLength=_this$props2.dotsLength,dotColor=_this$props2.dotColor,dotContainerStyle=_this$props2.dotContainerStyle,dotElement=_this$props2.dotElement,dotStyle=_this$props2.dotStyle,inactiveDotColor=_this$props2.inactiveDotColor,inactiveDotElement=_this$props2.inactiveDotElement,inactiveDotOpacity=_this$props2.inactiveDotOpacity,inactiveDotScale=_this$props2.inactiveDotScale,inactiveDotStyle=_this$props2.inactiveDotStyle,renderDots=_this$props2.renderDots,tappableDots=_this$props2.tappableDots;if(renderDots){return renderDots(this._activeDotIndex,dotsLength,this);}var DefaultDot=_react.default.createElement(_PaginationDot.default,{carouselRef:carouselRef,tappable:tappableDots&&typeof carouselRef!=='undefined',activeOpacity:activeOpacity,color:dotColor,containerStyle:dotContainerStyle,style:dotStyle,inactiveColor:inactiveDotColor,inactiveOpacity:inactiveDotOpacity,inactiveScale:inactiveDotScale,inactiveStyle:inactiveDotStyle,__source:{fileName:_jsxFileName,lineNumber:70,columnNumber:13}});var dots=[];for(var i=0;i<dotsLength;i+=1){var isActive=i===this._activeDotIndex;dots.push(_react.default.cloneElement((isActive?dotElement:inactiveDotElement)||DefaultDot,{key:"pagination-dot-"+i,active:i===this._activeDotIndex,index:i}));}return dots;}},{key:"render",value:function render(){var _this$props3=this.props,dotsLength=_this$props3.dotsLength,containerStyle=_this$props3.containerStyle,vertical=_this$props3.vertical,accessibilityLabel=_this$props3.accessibilityLabel;if(!dotsLength||dotsLength<2){return false;}var style=[_styles.default.sliderPagination,{flexDirection:vertical?'column':this._needsRTLAdaptations()?'row-reverse':'row'},containerStyle||{}];return _react.default.createElement(_reactNative.View,{pointerEvents:"box-none",style:style,accessible:!!accessibilityLabel,accessibilityLabel:accessibilityLabel,__source:{fileName:_jsxFileName,lineNumber:121,columnNumber:13}},this.dots);}}]);return Pagination;}(_react.PureComponent);exports.default=Pagination;Pagination.propTypes={activeDotIndex:_propTypes.default.number.isRequired,dotsLength:_propTypes.default.number.isRequired,activeOpacity:_propTypes.default.number,carouselRef:_propTypes.default.object,dotColor:_propTypes.default.string,dotElement:_propTypes.default.element,dotStyle:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array]),inactiveDotColor:_propTypes.default.string,inactiveDotElement:_propTypes.default.element,inactiveDotOpacity:_propTypes.default.number,inactiveDotScale:_propTypes.default.number,inactiveDotStyle:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array]),renderDots:_propTypes.default.func,tappableDots:_propTypes.default.bool,vertical:_propTypes.default.bool,accessibilityLabel:_propTypes.default.string,containerStyle:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array]),dotContainerStyle:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array])};Pagination.defaultProps={inactiveDotOpacity:0.5,inactiveDotScale:0.5,tappableDots:false,vertical:false};
1
+ import React, { PureComponent } from 'react';
2
+ import {
3
+ I18nManager, Platform, View
4
+ } from 'react-native';
5
+ import PropTypes from 'prop-types';
6
+ import PaginationDot from './PaginationDot';
7
+ import styles from './styles';
8
+
9
+ const IS_IOS = Platform.OS === 'ios';
10
+ const IS_RTL = I18nManager.isRTL;
11
+
12
+ export default class Pagination extends PureComponent {
13
+ constructor(props) {
14
+ super(props);
15
+
16
+ // Warnings
17
+ if ((props.dotColor && !props.inactiveDotColor) || (!props.dotColor && props.inactiveDotColor)) {
18
+ console.warn(
19
+ 'react-native-snap-carousel | Pagination: '
20
+ + 'You need to specify both `dotColor` and `inactiveDotColor`'
21
+ );
22
+ }
23
+ if ((props.dotElement && !props.inactiveDotElement) || (!props.dotElement && props.inactiveDotElement)) {
24
+ console.warn(
25
+ 'react-native-snap-carousel | Pagination: '
26
+ + 'You need to specify both `dotElement` and `inactiveDotElement`'
27
+ );
28
+ }
29
+ if (props.tappableDots && !props.carouselRef) {
30
+ console.warn(
31
+ 'react-native-snap-carousel | Pagination: '
32
+ + 'You must specify prop `carouselRef` when setting `tappableDots` to `true`'
33
+ );
34
+ }
35
+ }
36
+
37
+ _needsRTLAdaptations() {
38
+ const { vertical } = this.props;
39
+ return IS_RTL && !IS_IOS && !vertical;
40
+ }
41
+
42
+ get _activeDotIndex() {
43
+ const { activeDotIndex, dotsLength } = this.props;
44
+ return this._needsRTLAdaptations() ? dotsLength - activeDotIndex - 1 : activeDotIndex;
45
+ }
46
+
47
+ get dots() {
48
+ const {
49
+ activeOpacity,
50
+ carouselRef,
51
+ dotsLength,
52
+ dotColor,
53
+ dotContainerStyle,
54
+ dotElement,
55
+ dotStyle,
56
+ inactiveDotColor,
57
+ inactiveDotElement,
58
+ inactiveDotOpacity,
59
+ inactiveDotScale,
60
+ inactiveDotStyle,
61
+ renderDots,
62
+ tappableDots
63
+ } = this.props;
64
+
65
+ if (renderDots) {
66
+ return renderDots(this._activeDotIndex, dotsLength, this);
67
+ }
68
+
69
+ const DefaultDot = (
70
+ <PaginationDot
71
+ carouselRef={carouselRef}
72
+ tappable={tappableDots && typeof carouselRef !== 'undefined'}
73
+ activeOpacity={activeOpacity}
74
+ color={dotColor}
75
+ containerStyle={dotContainerStyle}
76
+ style={dotStyle}
77
+ inactiveColor={inactiveDotColor}
78
+ inactiveOpacity={inactiveDotOpacity}
79
+ inactiveScale={inactiveDotScale}
80
+ inactiveStyle={inactiveDotStyle}
81
+ />
82
+ );
83
+
84
+ const dots = [];
85
+
86
+ for (let i = 0; i < dotsLength; i += 1) {
87
+ const isActive = i === this._activeDotIndex;
88
+ dots.push(React.cloneElement(
89
+ (isActive ? dotElement : inactiveDotElement) || DefaultDot,
90
+ {
91
+ key: `pagination-dot-${i}`,
92
+ active: i === this._activeDotIndex,
93
+ index: i
94
+ }
95
+ ));
96
+ }
97
+
98
+ return dots;
99
+ }
100
+
101
+ render() {
102
+ const {
103
+ dotsLength, containerStyle, vertical, accessibilityLabel
104
+ } = this.props;
105
+
106
+ if (!dotsLength || dotsLength < 2) {
107
+ return false;
108
+ }
109
+
110
+ const style = [
111
+ styles.sliderPagination,
112
+ {
113
+ flexDirection: vertical
114
+ ? 'column'
115
+ : (this._needsRTLAdaptations() ? 'row-reverse' : 'row')
116
+ },
117
+ containerStyle || {}
118
+ ];
119
+
120
+ return (
121
+ <View
122
+ pointerEvents="box-none"
123
+ style={style}
124
+ accessible={!!accessibilityLabel}
125
+ accessibilityLabel={accessibilityLabel}
126
+ >
127
+ { this.dots }
128
+ </View>
129
+ );
130
+ }
131
+ }
132
+ Pagination.propTypes = {
133
+ activeDotIndex: PropTypes.number.isRequired,
134
+ dotsLength: PropTypes.number.isRequired,
135
+ activeOpacity: PropTypes.number,
136
+ carouselRef: PropTypes.object,
137
+ dotColor: PropTypes.string,
138
+ dotElement: PropTypes.element,
139
+ dotStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
140
+ inactiveDotColor: PropTypes.string,
141
+ inactiveDotElement: PropTypes.element,
142
+ inactiveDotOpacity: PropTypes.number,
143
+ inactiveDotScale: PropTypes.number,
144
+ inactiveDotStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
145
+ renderDots: PropTypes.func,
146
+ tappableDots: PropTypes.bool,
147
+ vertical: PropTypes.bool,
148
+ accessibilityLabel: PropTypes.string,
149
+ containerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
150
+ dotContainerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
151
+ };
152
+
153
+ Pagination.defaultProps = {
154
+ inactiveDotOpacity: 0.5,
155
+ inactiveDotScale: 0.5,
156
+ tappableDots: false,
157
+ vertical: false
158
+ };
@@ -1 +1,145 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _propTypes=_interopRequireDefault(require("prop-types"));var _styles=_interopRequireDefault(require("./styles"));var _jsxFileName="/Users/trinh.ho2/momo-folk/kits/src/libs/carousel/dist/pagination/PaginationDot.js";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});}keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2.default)(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2.default)(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2.default)(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}var PaginationDot=function(_PureComponent){(0,_inherits2.default)(PaginationDot,_PureComponent);var _super=_createSuper(PaginationDot);function PaginationDot(props){var _this;(0,_classCallCheck2.default)(this,PaginationDot);_this=_super.call(this,props);_this.state={animColor:new _reactNative.Animated.Value(0),animOpacity:new _reactNative.Animated.Value(0),animTransform:new _reactNative.Animated.Value(0)};return _this;}(0,_createClass2.default)(PaginationDot,[{key:"componentDidMount",value:function componentDidMount(){var active=this.props.active;if(active){this._animate(1);}}},{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(nextProps){var active=this.props.active;if(nextProps.active!==active){this._animate(nextProps.active?1:0);}}},{key:"_animate",value:function _animate(){var toValue=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var _this$state=this.state,animColor=_this$state.animColor,animOpacity=_this$state.animOpacity,animTransform=_this$state.animTransform;var commonProperties={toValue:toValue,duration:250,isInteraction:false,useNativeDriver:!this._shouldAnimateColor};var animations=[_reactNative.Animated.timing(animOpacity,_objectSpread({easing:_reactNative.Easing.linear},commonProperties)),_reactNative.Animated.spring(animTransform,_objectSpread({friction:4,tension:50},commonProperties))];if(this._shouldAnimateColor){animations.push(_reactNative.Animated.timing(animColor,_objectSpread({easing:_reactNative.Easing.linear},commonProperties)));}_reactNative.Animated.parallel(animations).start();}},{key:"_shouldAnimateColor",get:function get(){var _this$props=this.props,color=_this$props.color,inactiveColor=_this$props.inactiveColor;return color&&inactiveColor;}},{key:"render",value:function render(){var _this$state2=this.state,animColor=_this$state2.animColor,animOpacity=_this$state2.animOpacity,animTransform=_this$state2.animTransform;var _this$props2=this.props,active=_this$props2.active,activeOpacity=_this$props2.activeOpacity,carouselRef=_this$props2.carouselRef,color=_this$props2.color,containerStyle=_this$props2.containerStyle,inactiveColor=_this$props2.inactiveColor,inactiveStyle=_this$props2.inactiveStyle,inactiveOpacity=_this$props2.inactiveOpacity,inactiveScale=_this$props2.inactiveScale,index=_this$props2.index,style=_this$props2.style,tappable=_this$props2.tappable;var animatedStyle={opacity:animOpacity.interpolate({inputRange:[0,1],outputRange:[inactiveOpacity,1]}),transform:[{scale:animTransform.interpolate({inputRange:[0,1],outputRange:[inactiveScale,1]})}]};var animatedColor=this._shouldAnimateColor?{backgroundColor:animColor.interpolate({inputRange:[0,1],outputRange:[inactiveColor,color]})}:{};var dotContainerStyle=[_styles.default.sliderPaginationDotContainer,containerStyle||{}];var dotStyle=[_styles.default.sliderPaginationDot,style||{},!active&&inactiveStyle||{},animatedStyle,animatedColor];var onPress=tappable?function(){return carouselRef&&carouselRef._snapToItem(carouselRef._getPositionIndex(index));}:undefined;return _react.default.createElement(_reactNative.TouchableOpacity,{accessible:false,style:dotContainerStyle,activeOpacity:tappable?activeOpacity:1,onPress:onPress,__source:{fileName:_jsxFileName,lineNumber:121,columnNumber:13}},_react.default.createElement(_reactNative.Animated.View,{style:dotStyle,__source:{fileName:_jsxFileName,lineNumber:127,columnNumber:17}}));}}]);return PaginationDot;}(_react.PureComponent);exports.default=PaginationDot;PaginationDot.propTypes={inactiveOpacity:_propTypes.default.number.isRequired,inactiveScale:_propTypes.default.number.isRequired,active:_propTypes.default.bool,activeOpacity:_propTypes.default.number,carouselRef:_propTypes.default.object,color:_propTypes.default.string,inactiveColor:_propTypes.default.string,index:_propTypes.default.number,tappable:_propTypes.default.bool,style:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array]),containerStyle:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array]),inactiveStyle:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.array])};
1
+ import React, { PureComponent } from 'react';
2
+ import {
3
+ Animated, Easing, TouchableOpacity
4
+ } from 'react-native';
5
+ import PropTypes from 'prop-types';
6
+ import styles from './styles';
7
+
8
+ export default class PaginationDot extends PureComponent {
9
+ constructor(props) {
10
+ super(props);
11
+ this.state = {
12
+ animColor: new Animated.Value(0),
13
+ animOpacity: new Animated.Value(0),
14
+ animTransform: new Animated.Value(0)
15
+ };
16
+ }
17
+
18
+ componentDidMount() {
19
+ const { active } = this.props;
20
+ if (active) {
21
+ this._animate(1);
22
+ }
23
+ }
24
+
25
+ UNSAFE_componentWillReceiveProps(nextProps) {
26
+ const { active } = this.props;
27
+ if (nextProps.active !== active) {
28
+ this._animate(nextProps.active ? 1 : 0);
29
+ }
30
+ }
31
+
32
+ _animate(toValue = 0) {
33
+ const { animColor, animOpacity, animTransform } = this.state;
34
+
35
+ const commonProperties = {
36
+ toValue,
37
+ duration: 250,
38
+ isInteraction: false,
39
+ useNativeDriver: !this._shouldAnimateColor
40
+ };
41
+
42
+ const animations = [
43
+ Animated.timing(animOpacity, {
44
+ easing: Easing.linear,
45
+ ...commonProperties
46
+ }),
47
+ Animated.spring(animTransform, {
48
+ friction: 4,
49
+ tension: 50,
50
+ ...commonProperties
51
+ })
52
+ ];
53
+
54
+ if (this._shouldAnimateColor) {
55
+ animations.push(Animated.timing(animColor, {
56
+ easing: Easing.linear,
57
+ ...commonProperties
58
+ }));
59
+ }
60
+
61
+ Animated.parallel(animations).start();
62
+ }
63
+
64
+ get _shouldAnimateColor() {
65
+ const { color, inactiveColor } = this.props;
66
+ return color && inactiveColor;
67
+ }
68
+
69
+ render() {
70
+ const { animColor, animOpacity, animTransform } = this.state;
71
+ const {
72
+ active,
73
+ activeOpacity,
74
+ carouselRef,
75
+ color,
76
+ containerStyle,
77
+ inactiveColor,
78
+ inactiveStyle,
79
+ inactiveOpacity,
80
+ inactiveScale,
81
+ index,
82
+ style,
83
+ tappable
84
+ } = this.props;
85
+
86
+ const animatedStyle = {
87
+ opacity: animOpacity.interpolate({
88
+ inputRange: [0, 1],
89
+ outputRange: [inactiveOpacity, 1]
90
+ }),
91
+ transform: [{
92
+ scale: animTransform.interpolate({
93
+ inputRange: [0, 1],
94
+ outputRange: [inactiveScale, 1]
95
+ })
96
+ }]
97
+ };
98
+ const animatedColor = this._shouldAnimateColor ? {
99
+ backgroundColor: animColor.interpolate({
100
+ inputRange: [0, 1],
101
+ outputRange: [inactiveColor, color]
102
+ })
103
+ } : {};
104
+
105
+ const dotContainerStyle = [
106
+ styles.sliderPaginationDotContainer,
107
+ containerStyle || {}
108
+ ];
109
+
110
+ const dotStyle = [
111
+ styles.sliderPaginationDot,
112
+ style || {},
113
+ (!active && inactiveStyle) || {},
114
+ animatedStyle,
115
+ animatedColor
116
+ ];
117
+
118
+ const onPress = tappable ? () => carouselRef && carouselRef._snapToItem(carouselRef._getPositionIndex(index)) : undefined;
119
+
120
+ return (
121
+ <TouchableOpacity
122
+ accessible={false}
123
+ style={dotContainerStyle}
124
+ activeOpacity={tappable ? activeOpacity : 1}
125
+ onPress={onPress}
126
+ >
127
+ <Animated.View style={dotStyle} />
128
+ </TouchableOpacity>
129
+ );
130
+ }
131
+ }
132
+ PaginationDot.propTypes = {
133
+ inactiveOpacity: PropTypes.number.isRequired,
134
+ inactiveScale: PropTypes.number.isRequired,
135
+ active: PropTypes.bool,
136
+ activeOpacity: PropTypes.number,
137
+ carouselRef: PropTypes.object,
138
+ color: PropTypes.string,
139
+ inactiveColor: PropTypes.string,
140
+ index: PropTypes.number,
141
+ tappable: PropTypes.bool,
142
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
143
+ containerStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
144
+ inactiveStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
145
+ };
@@ -1 +1,24 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var DEFAULT_DOT_SIZE=7;var DEFAULT_DOT_COLOR='rgba(0, 0, 0, 0.75)';var _default=_reactNative.StyleSheet.create({sliderPagination:{alignItems:'center',justifyContent:'center',paddingHorizontal:20},sliderPaginationDotContainer:{alignItems:'center',justifyContent:'center',marginHorizontal:8},sliderPaginationDot:{width:DEFAULT_DOT_SIZE,height:DEFAULT_DOT_SIZE,borderRadius:DEFAULT_DOT_SIZE/2,backgroundColor:DEFAULT_DOT_COLOR}});exports.default=_default;
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ const DEFAULT_DOT_SIZE = 7;
4
+ const DEFAULT_DOT_COLOR = 'rgba(0, 0, 0, 0.75)';
5
+
6
+ export default StyleSheet.create({
7
+ sliderPagination: {
8
+ alignItems: 'center',
9
+ justifyContent: 'center',
10
+ paddingHorizontal: 20,
11
+ // paddingVertical: 30
12
+ },
13
+ sliderPaginationDotContainer: {
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ marginHorizontal: 8
17
+ },
18
+ sliderPaginationDot: {
19
+ width: DEFAULT_DOT_SIZE,
20
+ height: DEFAULT_DOT_SIZE,
21
+ borderRadius: DEFAULT_DOT_SIZE / 2,
22
+ backgroundColor: DEFAULT_DOT_COLOR
23
+ }
24
+ });
package/publish.sh CHANGED
@@ -12,7 +12,7 @@ echo VERSION: $VERSION
12
12
  rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
13
13
 
14
14
  # #babel component to dist
15
- babel ./dist -d dist --copy-files
15
+ #babel ./dist -d dist --copy-files
16
16
 
17
17
  #copy option
18
18
  #cp -r ./src/ dist
@@ -26,4 +26,4 @@ cd ..
26
26
  rm -rf dist
27
27
 
28
28
 
29
- echo '{"text": "@momo-kits/carousel new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/carousel"}'
29
+ curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/carousel new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/carousel"}'
package/styles.js CHANGED
@@ -1 +1,189 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.itemWidth=exports.sliderWidth=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _reactNative=require("react-native");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});}keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}var IS_IOS=_reactNative.Platform.OS==='ios';var _Dimensions$get=_reactNative.Dimensions.get('window'),viewportWidth=_Dimensions$get.width,viewportHeight=_Dimensions$get.height;function wp(percentage){var value=percentage*viewportWidth/100;return Math.round(value);}var slideHeight=viewportHeight*0.36;var slideWidth=wp(75);var itemHorizontalMargin=wp(2);var sliderWidth=viewportWidth;exports.sliderWidth=sliderWidth;var itemWidth=slideWidth+itemHorizontalMargin*2;exports.itemWidth=itemWidth;var entryBorderRadius=8;var styles=_reactNative.StyleSheet.create({container:{flex:1},contentView:{paddingTop:20,backgroundColor:'#1a191c'},divide:{width:viewportWidth,height:30},txtHeading:{marginVertical:15,marginLeft:10,fontSize:15,color:'#000'},dotsArea:{paddingVertical:5,position:'absolute',left:0,right:0,bottom:0},dotContainer:{borderWidth:1,borderColor:'#DADADA',width:8,height:8,borderRadius:4,marginHorizontal:5},safeArea:{flex:1,backgroundColor:'#000'},gradient:_objectSpread({},_reactNative.StyleSheet.absoluteFillObject),scrollview:{flex:1},exampleContainer:{paddingVertical:30},exampleContainerDark:{backgroundColor:'#F3F3F3'},exampleContainerLight:{backgroundColor:'transparent'},title:{paddingHorizontal:30,backgroundColor:'transparent',color:'#000',fontSize:20,fontWeight:'bold',textAlign:'center'},titleDark:{color:'#000'},subtitle:{marginTop:5,paddingHorizontal:30,backgroundColor:'transparent',color:'#000',fontSize:13,fontStyle:'italic',textAlign:'center'},slider:{marginTop:15,overflow:'visible'},sliderContentContainer:{paddingVertical:10},paginationContainer:{paddingVertical:8},paginationDot:{width:8,height:8,borderRadius:4,marginHorizontal:8},slideInnerContainer:{width:itemWidth,height:slideHeight,paddingHorizontal:itemHorizontalMargin,paddingBottom:18},shadow:{position:'absolute',top:0,left:itemHorizontalMargin,right:itemHorizontalMargin,bottom:18,shadowColor:'#000',shadowOpacity:0.25,shadowOffset:{width:0,height:10},shadowRadius:10,borderRadius:entryBorderRadius},imageContainer:{flex:1,marginBottom:IS_IOS?0:-1,backgroundColor:'white',borderTopLeftRadius:entryBorderRadius,borderTopRightRadius:entryBorderRadius},imageContainerEven:{backgroundColor:'#000'},image:_objectSpread(_objectSpread({},_reactNative.StyleSheet.absoluteFillObject),{},{resizeMode:'cover',borderRadius:IS_IOS?entryBorderRadius:0,borderTopLeftRadius:entryBorderRadius,borderTopRightRadius:entryBorderRadius}),radiusMask:{position:'absolute',bottom:0,left:0,right:0,height:entryBorderRadius,backgroundColor:'white'},radiusMaskEven:{backgroundColor:'#000'},textContainer:{justifyContent:'center',paddingTop:20-entryBorderRadius,paddingBottom:20,paddingHorizontal:16,backgroundColor:'white',borderBottomLeftRadius:entryBorderRadius,borderBottomRightRadius:entryBorderRadius},textContainerEven:{backgroundColor:'#000'},titleItem:{color:'#000',fontSize:13,fontWeight:'bold',letterSpacing:0.5},titleEven:{color:'white'},subtitleItem:{marginTop:6,color:'black',fontSize:12,fontStyle:'italic'},subtitleEven:{color:'rgba(255, 255, 255, 0.7)'}});var _default=styles;exports.default=_default;
1
+
2
+ import {
3
+ StyleSheet, Dimensions, Platform
4
+ } from 'react-native';
5
+
6
+ const IS_IOS = Platform.OS === 'ios';
7
+ const { width: viewportWidth, height: viewportHeight } = Dimensions.get('window');
8
+
9
+ function wp(percentage) {
10
+ const value = (percentage * viewportWidth) / 100;
11
+ return Math.round(value);
12
+ }
13
+
14
+ const slideHeight = viewportHeight * 0.36;
15
+ const slideWidth = wp(75);
16
+ const itemHorizontalMargin = wp(2);
17
+
18
+ export const sliderWidth = viewportWidth;
19
+ export const itemWidth = slideWidth + itemHorizontalMargin * 2;
20
+
21
+ const entryBorderRadius = 8;
22
+
23
+ const styles = StyleSheet.create({
24
+ container: {
25
+ flex: 1
26
+ },
27
+ contentView: {
28
+ paddingTop: 20,
29
+ backgroundColor: '#1a191c'
30
+ },
31
+ divide: {
32
+ width: viewportWidth,
33
+ height: 30
34
+ },
35
+ txtHeading: {
36
+ marginVertical: 15,
37
+ marginLeft: 10,
38
+ fontSize: 15,
39
+ color: '#000'
40
+ },
41
+ dotsArea: {
42
+ paddingVertical: 5,
43
+ position: 'absolute',
44
+ left: 0,
45
+ right: 0,
46
+ bottom: 0
47
+ },
48
+ dotContainer: {
49
+ borderWidth: 1,
50
+ borderColor: '#DADADA',
51
+ width: 8,
52
+ height: 8,
53
+ borderRadius: 4,
54
+ marginHorizontal: 5
55
+ },
56
+ safeArea: {
57
+ flex: 1,
58
+ backgroundColor: '#000'
59
+ },
60
+ gradient: {
61
+ ...StyleSheet.absoluteFillObject
62
+ },
63
+ scrollview: {
64
+ flex: 1
65
+ },
66
+ exampleContainer: {
67
+ paddingVertical: 30
68
+ },
69
+ exampleContainerDark: {
70
+ backgroundColor: '#F3F3F3'
71
+ },
72
+ exampleContainerLight: {
73
+ backgroundColor: 'transparent'
74
+ },
75
+ title: {
76
+ paddingHorizontal: 30,
77
+ backgroundColor: 'transparent',
78
+ color: '#000',
79
+ fontSize: 20,
80
+ fontWeight: 'bold',
81
+ textAlign: 'center'
82
+ },
83
+ titleDark: {
84
+ color: '#000'
85
+ },
86
+ subtitle: {
87
+ marginTop: 5,
88
+ paddingHorizontal: 30,
89
+ backgroundColor: 'transparent',
90
+ color: '#000',
91
+ fontSize: 13,
92
+ fontStyle: 'italic',
93
+ textAlign: 'center'
94
+ },
95
+ slider: {
96
+ marginTop: 15,
97
+ overflow: 'visible' // for custom animations
98
+ },
99
+ sliderContentContainer: {
100
+ paddingVertical: 10 // for custom animation
101
+ },
102
+ paginationContainer: {
103
+ paddingVertical: 8
104
+ },
105
+ paginationDot: {
106
+ width: 8,
107
+ height: 8,
108
+ borderRadius: 4,
109
+ marginHorizontal: 8
110
+ },
111
+ slideInnerContainer: {
112
+ width: itemWidth,
113
+ height: slideHeight,
114
+ paddingHorizontal: itemHorizontalMargin,
115
+ paddingBottom: 18 // needed for shadow
116
+ },
117
+ shadow: {
118
+ position: 'absolute',
119
+ top: 0,
120
+ left: itemHorizontalMargin,
121
+ right: itemHorizontalMargin,
122
+ bottom: 18,
123
+ shadowColor: '#000',
124
+ shadowOpacity: 0.25,
125
+ shadowOffset: { width: 0, height: 10 },
126
+ shadowRadius: 10,
127
+ borderRadius: entryBorderRadius
128
+ },
129
+ imageContainer: {
130
+ flex: 1,
131
+ marginBottom: IS_IOS ? 0 : -1, // Prevent a random Android rendering issue
132
+ backgroundColor: 'white',
133
+ borderTopLeftRadius: entryBorderRadius,
134
+ borderTopRightRadius: entryBorderRadius
135
+ },
136
+ imageContainerEven: {
137
+ backgroundColor: '#000'
138
+ },
139
+ image: {
140
+ ...StyleSheet.absoluteFillObject,
141
+ resizeMode: 'cover',
142
+ borderRadius: IS_IOS ? entryBorderRadius : 0,
143
+ borderTopLeftRadius: entryBorderRadius,
144
+ borderTopRightRadius: entryBorderRadius
145
+ },
146
+ // image's border radius is buggy on iOS; let's hack it!
147
+ radiusMask: {
148
+ position: 'absolute',
149
+ bottom: 0,
150
+ left: 0,
151
+ right: 0,
152
+ height: entryBorderRadius,
153
+ backgroundColor: 'white'
154
+ },
155
+ radiusMaskEven: {
156
+ backgroundColor: '#000'
157
+ },
158
+ textContainer: {
159
+ justifyContent: 'center',
160
+ paddingTop: 20 - entryBorderRadius,
161
+ paddingBottom: 20,
162
+ paddingHorizontal: 16,
163
+ backgroundColor: 'white',
164
+ borderBottomLeftRadius: entryBorderRadius,
165
+ borderBottomRightRadius: entryBorderRadius
166
+ },
167
+ textContainerEven: {
168
+ backgroundColor: '#000'
169
+ },
170
+ titleItem: {
171
+ color: '#000',
172
+ fontSize: 13,
173
+ fontWeight: 'bold',
174
+ letterSpacing: 0.5
175
+ },
176
+ titleEven: {
177
+ color: 'white'
178
+ },
179
+ subtitleItem: {
180
+ marginTop: 6,
181
+ color: 'black',
182
+ fontSize: 12,
183
+ fontStyle: 'italic'
184
+ },
185
+ subtitleEven: {
186
+ color: 'rgba(255, 255, 255, 0.7)'
187
+ }
188
+ });
189
+ export default styles;