From 98eff075765e36f09624e422e3ca81b26c723c3c Mon Sep 17 00:00:00 2001 From: Denise Date: Wed, 18 Aug 2021 17:55:58 +0800 Subject: [PATCH] feat: use native driver for animation --- example/ios/Podfile | 8 ++++---- lib/awesome-modal.js | 21 +++++++++++++-------- lib/awesome-modal.js.map | 2 +- package.json | 2 +- src/awesome-modal.tsx | 28 +++++++++++++--------------- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index 9b85987..5b9b4c4 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -18,10 +18,10 @@ target 'example' do # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable these next few lines. - use_flipper! - post_install do |installer| - flipper_post_install(installer) - end +# use_flipper! +# post_install do |installer| +# flipper_post_install(installer) +# end end target 'example-tvOS' do diff --git a/lib/awesome-modal.js b/lib/awesome-modal.js index f774201..48342b1 100644 --- a/lib/awesome-modal.js +++ b/lib/awesome-modal.js @@ -46,7 +46,7 @@ class AwesomeModal extends React.Component { this.state = { modalHeight: 0, opacityAnimation: new react_native_1.Animated.Value(0), - translateYAnimation: new react_native_1.Animated.Value(DEVICE_HEIGHT * -1.5), + translateYAnimation: new react_native_1.Animated.Value(DEVICE_HEIGHT * 1.5), modalYPosition: props.modalBottomMargin ?? 0 + yPositionBottomMargin, deviceHeight: DEVICE_HEIGHT, overlayIsVisible: true, @@ -55,7 +55,8 @@ class AwesomeModal extends React.Component { this.onTouchOutside = this.onTouchOutside.bind(this); this.close = this.close.bind(this); this.onModalHeightChange = this.onModalHeightChange.bind(this); - this.onSafeAreaInsetsForRootViewChange = this.onSafeAreaInsetsForRootViewChange.bind(this); + this.onSafeAreaInsetsForRootViewChange = + this.onSafeAreaInsetsForRootViewChange.bind(this); } async componentDidMount() { // Assign the parent's ref to modalRef so that we can control @@ -112,9 +113,9 @@ class AwesomeModal extends React.Component { useNativeDriver: true, }), react_native_1.Animated.timing(translateYAnimation, { - toValue: this.state.deviceHeight * -1.5, + toValue: this.state.deviceHeight * 1.5, duration: 250, - useNativeDriver: false, + useNativeDriver: true, }), ]).start(() => { this.setState(() => { @@ -135,7 +136,7 @@ class AwesomeModal extends React.Component { * the application. */ onModalHeightChange() { - const { modalHeight, opacityAnimation, translateYAnimation, modalYPosition, } = this.state; + const { modalHeight, opacityAnimation, translateYAnimation } = this.state; if (modalHeight !== 0) { react_native_1.Animated.parallel([ react_native_1.Animated.timing(opacityAnimation, { @@ -146,8 +147,8 @@ class AwesomeModal extends React.Component { react_native_1.Animated.spring(translateYAnimation, { toValue: this.props.isCentered ? (DEVICE_HEIGHT - modalHeight) / 2 - : modalYPosition, - useNativeDriver: false, + : DEVICE_HEIGHT - modalHeight, + useNativeDriver: true, }), ]).start(); } @@ -252,7 +253,11 @@ class AwesomeModal extends React.Component { return { modalHeight: layoutHeight }; }); }} style={[ - { bottom: this.state.translateYAnimation }, + { + transform: [ + { translateY: this.state.translateYAnimation }, + ], + }, defaultModalContainerStyle, modalContainerStyle, ]}> diff --git a/lib/awesome-modal.js.map b/lib/awesome-modal.js.map index ab89ec4..7138d32 100644 --- a/lib/awesome-modal.js.map +++ b/lib/awesome-modal.js.map @@ -1 +1 @@ -{"version":3,"file":"awesome-modal.js","sourceRoot":"","sources":["../src/awesome-modal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAoC;AACpC,qDAA6B;AAC7B,6CAA8B;AAE9B,+CAWqB;AACrB,oFAAiE;AA0CjE,MAAM,aAAa,GAAG,yBAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;AAErD,MAAa,YAAa,SAAQ,KAAK,CAAC,SAAyB;IAC/D,aAAa,CAAuB;IAEpC,MAAM,CAAC,YAAY,GAAG;QACpB,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,mBAAmB,EAAE,IAAI;QACzB,iBAAiB,EAAE,EAAE;QACrB,UAAU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diff --git a/package.json b/package.json index 746848f..713823b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-awesome-modal", - "version": "0.1.1", + "version": "0.1.2", "description": "A flexible and reusable modal.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/awesome-modal.tsx b/src/awesome-modal.tsx index fa05013..8d3a784 100644 --- a/src/awesome-modal.tsx +++ b/src/awesome-modal.tsx @@ -80,7 +80,7 @@ export class AwesomeModal extends React.Component { this.state = { modalHeight: 0, opacityAnimation: new Animated.Value(0), - translateYAnimation: new Animated.Value(DEVICE_HEIGHT * -1.5), + translateYAnimation: new Animated.Value(DEVICE_HEIGHT * 1.5), modalYPosition: props.modalBottomMargin ?? 0 + yPositionBottomMargin, deviceHeight: DEVICE_HEIGHT, overlayIsVisible: true, @@ -91,9 +91,8 @@ export class AwesomeModal extends React.Component { this.onTouchOutside = this.onTouchOutside.bind(this) this.close = this.close.bind(this) this.onModalHeightChange = this.onModalHeightChange.bind(this) - this.onSafeAreaInsetsForRootViewChange = this.onSafeAreaInsetsForRootViewChange.bind( - this - ) + this.onSafeAreaInsetsForRootViewChange = + this.onSafeAreaInsetsForRootViewChange.bind(this) } async componentDidMount() { @@ -169,9 +168,9 @@ export class AwesomeModal extends React.Component { useNativeDriver: true, }), Animated.timing(translateYAnimation, { - toValue: this.state.deviceHeight * -1.5, + toValue: this.state.deviceHeight * 1.5, duration: 250, - useNativeDriver: false, + useNativeDriver: true, }), ]).start(() => { this.setState(() => { @@ -194,12 +193,7 @@ export class AwesomeModal extends React.Component { * the application. */ onModalHeightChange() { - const { - modalHeight, - opacityAnimation, - translateYAnimation, - modalYPosition, - } = this.state + const { modalHeight, opacityAnimation, translateYAnimation } = this.state if (modalHeight !== 0) { Animated.parallel([ @@ -211,8 +205,8 @@ export class AwesomeModal extends React.Component { Animated.spring(translateYAnimation, { toValue: this.props.isCentered ? (DEVICE_HEIGHT - modalHeight) / 2 - : modalYPosition, - useNativeDriver: false, + : DEVICE_HEIGHT - modalHeight, + useNativeDriver: true, }), ]).start() } @@ -345,7 +339,11 @@ export class AwesomeModal extends React.Component { }) }} style={[ - { bottom: this.state.translateYAnimation as any }, + { + transform: [ + { translateY: this.state.translateYAnimation as any }, + ], + }, defaultModalContainerStyle, modalContainerStyle, ]}