Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.

Commit d19ed21

Browse files
authored
Add compatibility with RN 0.62
RN 0.62 requires specify `useNativeDriver` Instead get warning message: WARN Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`
1 parent c537143 commit d19ed21

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/image-viewer.component.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export default class ImageViewer extends React.Component<Props, State> {
6969
// 显示动画
7070
Animated.timing(this.fadeAnim, {
7171
toValue: 1,
72-
duration: 200
72+
duration: 200,
73+
useNativeDriver: true
7374
}).start();
7475
}
7576
}
@@ -109,7 +110,8 @@ export default class ImageViewer extends React.Component<Props, State> {
109110
// 显示动画
110111
Animated.timing(this.fadeAnim, {
111112
toValue: 1,
112-
duration: 200
113+
duration: 200,
114+
useNativeDriver: true
113115
}).start();
114116
}
115117
);
@@ -304,7 +306,8 @@ export default class ImageViewer extends React.Component<Props, State> {
304306
this.standardPositionX = this.positionXNumber;
305307
Animated.timing(this.positionX, {
306308
toValue: this.positionXNumber,
307-
duration: this.props.pageAnimateTime
309+
duration: this.props.pageAnimateTime,
310+
useNativeDriver: true
308311
}).start();
309312

310313
const nextIndex = (this.state.currentShowIndex || 0) - 1;
@@ -337,7 +340,8 @@ export default class ImageViewer extends React.Component<Props, State> {
337340
this.standardPositionX = this.positionXNumber;
338341
Animated.timing(this.positionX, {
339342
toValue: this.positionXNumber,
340-
duration: this.props.pageAnimateTime
343+
duration: this.props.pageAnimateTime,
344+
useNativeDriver: true
341345
}).start();
342346

343347
const nextIndex = (this.state.currentShowIndex || 0) + 1;
@@ -361,7 +365,8 @@ export default class ImageViewer extends React.Component<Props, State> {
361365
this.positionXNumber = this.standardPositionX;
362366
Animated.timing(this.positionX, {
363367
toValue: this.standardPositionX,
364-
duration: 150
368+
duration: 150,
369+
useNativeDriver: true
365370
}).start();
366371
}
367372

0 commit comments

Comments
 (0)