react-native-kenburns-view 4.1.0 → 5.0.0

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.
Files changed (84) hide show
  1. package/README.md +48 -25
  2. package/example/kenburns-example/App.js +78 -0
  3. package/example/kenburns-example/README.md +32 -0
  4. package/example/kenburns-example/app.json +21 -0
  5. package/example/kenburns-example/babel.config.js +6 -0
  6. package/example/kenburns-example/ios/.xcode.env +11 -0
  7. package/example/kenburns-example/ios/KenBurnsExample/AppDelegate.h +7 -0
  8. package/example/kenburns-example/ios/KenBurnsExample/AppDelegate.mm +62 -0
  9. package/example/kenburns-example/ios/KenBurnsExample/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png +0 -0
  10. package/example/kenburns-example/ios/KenBurnsExample/Images.xcassets/AppIcon.appiconset/Contents.json +14 -0
  11. package/example/{KenBurnsExample/ios/KenBurnsExampleNew → kenburns-example/ios/KenBurnsExample}/Images.xcassets/Contents.json +1 -1
  12. package/example/kenburns-example/ios/KenBurnsExample/Images.xcassets/SplashScreenBackground.colorset/Contents.json +20 -0
  13. package/example/kenburns-example/ios/KenBurnsExample/Info.plist +74 -0
  14. package/example/kenburns-example/ios/KenBurnsExample/KenBurnsExample-Bridging-Header.h +3 -0
  15. package/example/kenburns-example/ios/KenBurnsExample/KenBurnsExample.entitlements +5 -0
  16. package/example/kenburns-example/ios/KenBurnsExample/PrivacyInfo.xcprivacy +37 -0
  17. package/example/kenburns-example/ios/KenBurnsExample/SplashScreen.storyboard +34 -0
  18. package/example/kenburns-example/ios/KenBurnsExample/Supporting/Expo.plist +12 -0
  19. package/example/{KenBurnsExample/ios/KenBurnsExampleNew → kenburns-example/ios/KenBurnsExample}/main.m +1 -7
  20. package/example/kenburns-example/ios/KenBurnsExample/noop-file.swift +4 -0
  21. package/example/kenburns-example/ios/KenBurnsExample.xcodeproj/project.pbxproj +536 -0
  22. package/example/{KenBurnsExample/ios/KenBurnsExampleNew.xcodeproj/xcshareddata/xcschemes/KenBurnsExampleNew.xcscheme → kenburns-example/ios/KenBurnsExample.xcodeproj/xcshareddata/xcschemes/KenBurnsExample.xcscheme} +14 -55
  23. package/example/kenburns-example/ios/KenBurnsExample.xcworkspace/contents.xcworkspacedata +10 -0
  24. package/example/kenburns-example/ios/Podfile +66 -0
  25. package/example/kenburns-example/ios/Podfile.lock +1828 -0
  26. package/example/kenburns-example/ios/Podfile.properties.json +5 -0
  27. package/example/kenburns-example/metro.config.js +17 -0
  28. package/example/kenburns-example/package-lock.json +10971 -0
  29. package/example/kenburns-example/package.json +21 -0
  30. package/lib/KenBurnsView.js +206 -106
  31. package/package.json +2 -5
  32. package/example/KenBurnsExample/.babelrc +0 -3
  33. package/example/KenBurnsExample/.buckconfig +0 -6
  34. package/example/KenBurnsExample/.flowconfig +0 -67
  35. package/example/KenBurnsExample/.gitattributes +0 -1
  36. package/example/KenBurnsExample/.snyk +0 -10
  37. package/example/KenBurnsExample/.watchmanconfig +0 -1
  38. package/example/KenBurnsExample/App.js +0 -64
  39. package/example/KenBurnsExample/android/app/BUCK +0 -65
  40. package/example/KenBurnsExample/android/app/build.gradle +0 -150
  41. package/example/KenBurnsExample/android/app/proguard-rules.pro +0 -17
  42. package/example/KenBurnsExample/android/app/src/main/AndroidManifest.xml +0 -26
  43. package/example/KenBurnsExample/android/app/src/main/java/com/kenburnsexamplenew/MainActivity.java +0 -15
  44. package/example/KenBurnsExample/android/app/src/main/java/com/kenburnsexamplenew/MainApplication.java +0 -45
  45. package/example/KenBurnsExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  46. package/example/KenBurnsExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  47. package/example/KenBurnsExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  48. package/example/KenBurnsExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  49. package/example/KenBurnsExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  50. package/example/KenBurnsExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  51. package/example/KenBurnsExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  52. package/example/KenBurnsExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  53. package/example/KenBurnsExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  54. package/example/KenBurnsExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  55. package/example/KenBurnsExample/android/app/src/main/res/values/strings.xml +0 -3
  56. package/example/KenBurnsExample/android/app/src/main/res/values/styles.xml +0 -8
  57. package/example/KenBurnsExample/android/build.gradle +0 -40
  58. package/example/KenBurnsExample/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  59. package/example/KenBurnsExample/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  60. package/example/KenBurnsExample/android/gradle.properties +0 -20
  61. package/example/KenBurnsExample/android/gradlew +0 -164
  62. package/example/KenBurnsExample/android/gradlew.bat +0 -90
  63. package/example/KenBurnsExample/android/keystores/BUCK +0 -8
  64. package/example/KenBurnsExample/android/keystores/debug.keystore.properties +0 -4
  65. package/example/KenBurnsExample/android/settings.gradle +0 -3
  66. package/example/KenBurnsExample/app.json +0 -4
  67. package/example/KenBurnsExample/index.js +0 -7
  68. package/example/KenBurnsExample/ios/KenBurnsExampleNew/AppDelegate.h +0 -14
  69. package/example/KenBurnsExample/ios/KenBurnsExampleNew/AppDelegate.m +0 -35
  70. package/example/KenBurnsExample/ios/KenBurnsExampleNew/Base.lproj/LaunchScreen.xib +0 -42
  71. package/example/KenBurnsExample/ios/KenBurnsExampleNew/Images.xcassets/AppIcon.appiconset/Contents.json +0 -38
  72. package/example/KenBurnsExample/ios/KenBurnsExampleNew/Info.plist +0 -56
  73. package/example/KenBurnsExample/ios/KenBurnsExampleNew-tvOS/Info.plist +0 -54
  74. package/example/KenBurnsExample/ios/KenBurnsExampleNew-tvOSTests/Info.plist +0 -24
  75. package/example/KenBurnsExample/ios/KenBurnsExampleNew.xcodeproj/project.pbxproj +0 -1468
  76. package/example/KenBurnsExample/ios/KenBurnsExampleNew.xcodeproj/xcshareddata/xcschemes/KenBurnsExampleNew-tvOS.xcscheme +0 -129
  77. package/example/KenBurnsExample/ios/KenBurnsExampleNewTests/Info.plist +0 -24
  78. package/example/KenBurnsExample/ios/KenBurnsExampleNewTests/KenBurnsExampleNewTests.m +0 -68
  79. package/example/KenBurnsExample/package.json +0 -27
  80. package/yarn.lock +0 -114
  81. /package/example/{KenBurnsExample → kenburns-example/assets}/images/image1.jpg +0 -0
  82. /package/example/{KenBurnsExample → kenburns-example/assets}/images/image2.jpg +0 -0
  83. /package/example/{KenBurnsExample → kenburns-example/assets}/images/image3.jpg +0 -0
  84. /package/example/{KenBurnsExample → kenburns-example/assets}/images/placeholder.jpg +0 -0
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "kenburns-example",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "start": "expo start",
7
+ "android": "expo run:android",
8
+ "ios": "expo run:ios"
9
+ },
10
+ "dependencies": {
11
+ "expo": "~52.0.0",
12
+ "expo-asset": "~11.0.1",
13
+ "expo-status-bar": "~2.0.0",
14
+ "react": "18.3.1",
15
+ "react-native": "0.76.5",
16
+ "react-native-kenburns-view": "file:../.."
17
+ },
18
+ "devDependencies": {
19
+ "@babel/core": "^7.25.2"
20
+ }
21
+ }
@@ -4,120 +4,220 @@
4
4
  *
5
5
  * Version: 4.1.0
6
6
  *
7
- * Description: This reflects the KenBurns effect in a React Native Image
7
+ * Description: Ken Burns effect (zoom + pan) for React Native images.
8
8
  */
9
9
 
10
- 'use strict';
11
- import React, {Component} from 'react';
10
+ import React, {
11
+ forwardRef,
12
+ useCallback,
13
+ useEffect,
14
+ useImperativeHandle,
15
+ useRef,
16
+ } from 'react';
12
17
  import PropTypes from 'prop-types';
13
- import rebound from 'rebound';
14
- import {Image, View} from 'react-native';
15
- import ReactTimeout from 'react-timeout';
16
-
17
- class KenBurnsView extends Component {
18
- static defaultProps = {
19
- tension: 6,
20
- friction: 50,
21
- min: 1.3,
22
- max: 1.6,
23
- autoStart: true,
24
- };
25
-
26
- state = {
27
- scale: null,
28
- };
29
-
30
- UNSAFE_componentWillMount() {
31
- if (!this._mounted) {
32
- this.springSystemFunctions();
33
- }
34
- }
35
-
36
- componentWillUnmount() {
37
- this._mounted = false;
38
- this._scrollSpring && this._scrollSpring.destroy();
39
- }
40
-
41
- springSystemFunctions() {
42
- this.springSystem = new rebound.SpringSystem();
43
- this._scrollSpring = this.springSystem.createSpring();
44
- var springConfig = this._scrollSpring.getSpringConfig();
45
- const {tension, friction} = this.props;
46
-
47
- springConfig.tension = tension;
48
- springConfig.friction = friction;
49
-
50
- this._scrollSpring.addListener({
51
- onSpringUpdate: () => {
52
- this.setState({scale: this._scrollSpring.getCurrentValue()});
53
- },
54
- });
55
-
56
- this._scrollSpring.setCurrentValue(1);
18
+ import {
19
+ Animated,
20
+ Easing,
21
+ ImageBackground,
22
+ StyleSheet,
23
+ View,
24
+ } from 'react-native';
25
+
26
+ const DEFAULT_DURATION = 20000;
27
+ const FILL_SCALE = 1.15;
28
+
29
+ const KenBurnsView = forwardRef((props, ref) => {
30
+ const {
31
+ imageWidth,
32
+ imageHeight,
33
+ sourceUri,
34
+ placeholderSource,
35
+ autoStart = true,
36
+ duration = DEFAULT_DURATION,
37
+ zoomStart = 1,
38
+ zoomEnd = 1.3,
39
+ panX = 0.1,
40
+ panY = 0.1,
41
+ children,
42
+ style,
43
+ ...rest
44
+ } = props;
45
+
46
+ const progress = useRef(new Animated.Value(0)).current;
47
+ const animationRef = useRef(null);
48
+
49
+ const randomRef = useRef({
50
+ phase: Math.random(),
51
+ durationFactor: 0.7 + Math.random() * 0.6,
52
+ panXSign: Math.random() > 0.5 ? 1 : -1,
53
+ panYSign: Math.random() > 0.5 ? 1 : -1,
54
+ }).current;
55
+
56
+ const stop = useCallback(() => {
57
+ if (animationRef.current) {
58
+ animationRef.current.stop();
59
+ animationRef.current = null;
57
60
  }
58
-
59
- componentDidMount() {
60
- this._mounted = true;
61
- const {autoStart} = this.props;
62
- if (autoStart) {
63
- this.animLoop();
64
- }
61
+ }, []);
62
+
63
+ const start = useCallback(() => {
64
+ stop();
65
+ progress.setValue(randomRef.phase);
66
+
67
+ const d = Math.round(duration * randomRef.durationFactor);
68
+
69
+ animationRef.current = Animated.loop(
70
+ Animated.sequence([
71
+ Animated.timing(progress, {
72
+ toValue: 1,
73
+ duration: d,
74
+ easing: Easing.inOut(Easing.quad),
75
+ useNativeDriver: true,
76
+ }),
77
+ Animated.timing(progress, {
78
+ toValue: 0,
79
+ duration: d,
80
+ easing: Easing.inOut(Easing.quad),
81
+ useNativeDriver: true,
82
+ }),
83
+ ]),
84
+ {resetBeforeIteration: false},
85
+ );
86
+
87
+ animationRef.current.start();
88
+ }, [duration, progress, stop, randomRef]);
89
+
90
+ useImperativeHandle(
91
+ ref,
92
+ () => ({
93
+ start,
94
+ stop,
95
+ reset: () => {
96
+ stop();
97
+ progress.setValue(0);
98
+ },
99
+ }),
100
+ [start, stop, progress],
101
+ );
102
+
103
+ useEffect(() => {
104
+ if (autoStart) {
105
+ start();
65
106
  }
66
107
 
67
- animLoop = () => {
68
- this.animationFunc();
69
-
70
- setTimeout(() => {
71
- this.animLoop();
72
- }, Math.floor((Math.random() * 11000) + 10000));
73
- };
74
-
75
- animationFunc = () => {
76
- const {min, max} = this.props;
77
- const endValue = parseFloat((Math.random() * (max - min) + min).toFixed(2));
78
- this._scrollSpring.setEndValue(endValue);
79
-
80
- setTimeout(() => {
81
- this._scrollSpring.setEndValue(1);
82
- }, Math.floor((Math.random() * 11000) + 10000));
108
+ return () => {
109
+ stop();
83
110
  };
84
-
85
- resetAnimation = () => {
86
- this._scrollSpring && this._scrollSpring.setCurrentValue(1);
87
- };
88
-
89
- render() {
90
- var imageStyle = {
91
- alignItems: 'stretch',
92
- width: this.props.imageWidth,
93
- height: this.props.imageHeight,
94
- transform: [
95
- {
96
- scale: this.state.scale,
97
- },
98
- ],
99
- };
100
-
101
- return (
102
- <View>
103
- <Image
104
- defaultSource={this.props.placeholderSource}
105
- source={this.props.sourceUri}
106
- style={imageStyle}
107
- >
108
- {this.props.children}
109
- </Image>
110
- </View>
111
- );
112
- }
113
- }
111
+ }, [autoStart, start, stop]);
112
+
113
+ const w = imageWidth || 0;
114
+ const h = imageHeight || 0;
115
+ const panXAmount = w * panX * randomRef.panXSign;
116
+ const panYAmount = h * panY * randomRef.panYSign;
117
+
118
+ const translateX = progress.interpolate({
119
+ inputRange: [0, 1],
120
+ outputRange: [-panXAmount, panXAmount],
121
+ });
122
+
123
+ const translateY = progress.interpolate({
124
+ inputRange: [0, 1],
125
+ outputRange: [-panYAmount, panYAmount],
126
+ });
127
+
128
+ const scale = progress.interpolate({
129
+ inputRange: [0, 1],
130
+ outputRange: [zoomStart, zoomEnd],
131
+ });
132
+
133
+ const innerSize = {
134
+ width: w * FILL_SCALE,
135
+ height: h * FILL_SCALE,
136
+ };
137
+ const innerOffset = {
138
+ left: -w * (FILL_SCALE - 1) / 2,
139
+ top: -h * (FILL_SCALE - 1) / 2,
140
+ };
141
+
142
+ const outerStyle = [
143
+ styles.outer,
144
+ {
145
+ width: imageWidth,
146
+ height: imageHeight,
147
+ },
148
+ style,
149
+ ];
150
+
151
+ const animatedStyle = {
152
+ ...innerSize,
153
+ ...innerOffset,
154
+ transform: [{scale}, {translateX}, {translateY}],
155
+ };
156
+
157
+ return (
158
+ <View style={outerStyle}>
159
+ <Animated.View style={[styles.inner, animatedStyle]}>
160
+ <ImageBackground
161
+ defaultSource={placeholderSource}
162
+ source={sourceUri}
163
+ style={styles.image}
164
+ imageStyle={styles.imageCover}
165
+ resizeMode="cover"
166
+ {...rest}>
167
+ {children}
168
+ </ImageBackground>
169
+ </Animated.View>
170
+ </View>
171
+ );
172
+ });
173
+
174
+ KenBurnsView.displayName = 'KenBurnsView';
114
175
 
115
176
  KenBurnsView.propTypes = {
116
- autoStart: PropTypes.bool,
117
- tension: PropTypes.number,
118
- friction: PropTypes.number,
119
- min: PropTypes.number,
120
- max: PropTypes.number,
177
+ autoStart: PropTypes.bool,
178
+ imageWidth: PropTypes.number.isRequired,
179
+ imageHeight: PropTypes.number.isRequired,
180
+ sourceUri: PropTypes.oneOfType([PropTypes.number, PropTypes.object])
181
+ .isRequired,
182
+ placeholderSource: PropTypes.oneOfType([
183
+ PropTypes.number,
184
+ PropTypes.object,
185
+ ]),
186
+ duration: PropTypes.number,
187
+ zoomStart: PropTypes.number,
188
+ zoomEnd: PropTypes.number,
189
+ panX: PropTypes.number,
190
+ panY: PropTypes.number,
191
+ children: PropTypes.node,
192
+ style: PropTypes.any,
193
+ };
194
+
195
+ KenBurnsView.defaultProps = {
196
+ autoStart: true,
197
+ duration: DEFAULT_DURATION,
198
+ zoomStart: 1,
199
+ zoomEnd: 1.3,
200
+ panX: 0.1,
201
+ panY: 0.1,
121
202
  };
122
203
 
123
- export default ReactTimeout(KenBurnsView);
204
+ const styles = StyleSheet.create({
205
+ outer: {
206
+ overflow: 'hidden',
207
+ position: 'relative',
208
+ },
209
+ inner: {
210
+ position: 'absolute',
211
+ },
212
+ image: {
213
+ ...StyleSheet.absoluteFillObject,
214
+ width: '100%',
215
+ height: '100%',
216
+ },
217
+ imageCover: {
218
+ width: '100%',
219
+ height: '100%',
220
+ },
221
+ });
222
+
223
+ export default KenBurnsView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-kenburns-view",
3
- "version": "4.1.0",
3
+ "version": "5.0.0",
4
4
  "description": "KenBurns Image Effect for React Native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,9 +27,6 @@
27
27
  "example": "example"
28
28
  },
29
29
  "dependencies": {
30
- "prop-types": "^15.6.0",
31
- "react-mixin": "2",
32
- "react-timer-mixin": "^0.13.3",
33
- "rebound": "^0.0.15"
30
+ "prop-types": "^15.8.1"
34
31
  }
35
32
  }
@@ -1,3 +0,0 @@
1
- {
2
- "presets": ["react-native"]
3
- }
@@ -1,6 +0,0 @@
1
-
2
- [android]
3
- target = Google Inc.:Google APIs:23
4
-
5
- [maven_repositories]
6
- central = https://repo1.maven.org/maven2
@@ -1,67 +0,0 @@
1
- [ignore]
2
- ; We fork some components by platform
3
- .*/*[.]android.js
4
-
5
- ; Ignore "BUCK" generated dirs
6
- <PROJECT_ROOT>/\.buckd/
7
-
8
- ; Ignore unexpected extra "@providesModule"
9
- .*/node_modules/.*/node_modules/fbjs/.*
10
-
11
- ; Ignore duplicate module providers
12
- ; For RN Apps installed via npm, "Libraries" folder is inside
13
- ; "node_modules/react-native" but in the source repo it is in the root
14
- .*/Libraries/react-native/React.js
15
-
16
- ; Ignore polyfills
17
- .*/Libraries/polyfills/.*
18
-
19
- ; Ignore metro
20
- .*/node_modules/metro/.*
21
-
22
- [include]
23
-
24
- [libs]
25
- node_modules/react-native/Libraries/react-native/react-native-interface.js
26
- node_modules/react-native/flow/
27
- node_modules/react-native/flow-github/
28
-
29
- [options]
30
- emoji=true
31
-
32
- module.system=haste
33
- module.system.haste.use_name_reducers=true
34
- # get basename
35
- module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
36
- # strip .js or .js.flow suffix
37
- module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
38
- # strip .ios suffix
39
- module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
40
- module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
41
- module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
42
- module.system.haste.paths.blacklist=.*/__tests__/.*
43
- module.system.haste.paths.blacklist=.*/__mocks__/.*
44
- module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
45
- module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
46
-
47
- munge_underscores=true
48
-
49
- module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
50
-
51
- module.file_ext=.js
52
- module.file_ext=.jsx
53
- module.file_ext=.json
54
- module.file_ext=.native.js
55
-
56
- suppress_type=$FlowIssue
57
- suppress_type=$FlowFixMe
58
- suppress_type=$FlowFixMeProps
59
- suppress_type=$FlowFixMeState
60
-
61
- suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
62
- suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
63
- suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
64
- suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
65
-
66
- [version]
67
- ^0.75.0
@@ -1 +0,0 @@
1
- *.pbxproj -text
@@ -1,10 +0,0 @@
1
- # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2
- version: v1.13.5
3
- ignore: {}
4
- # patches apply the minimum changes required to fix a vulnerability
5
- patch:
6
- SNYK-JS-LODASH-450202:
7
- - react-native > metro-babel-register > @babel/core > lodash:
8
- patched: '2019-07-30T00:35:40.351Z'
9
- - react-native > metro-babel-register > @babel/core > @babel/generator > lodash:
10
- patched: '2019-07-30T00:35:40.351Z'
@@ -1 +0,0 @@
1
- {}
@@ -1,64 +0,0 @@
1
- /**
2
- * Sample React Native App
3
- * https://github.com/facebook/react-native
4
- *
5
- * @format
6
- * @flow
7
- */
8
-
9
- import React, {Component} from 'react';
10
- import {Platform, StyleSheet, Text, View} from 'react-native';
11
-
12
- import KenBurnsImage from 'react-native-kenburns-view';
13
- const Dimensions = require('Dimensions');
14
-
15
- type Props = {};
16
- export default class App extends Component<Props> {
17
- render() {
18
- return (
19
- <View style={styles.container}>
20
- <Text style={styles.title}>
21
- Using KenBurns View!
22
- </Text>
23
- <View style={styles.imageContainer}>
24
- <KenBurnsImage tension={6} friction={50} imageWidth={Dimensions.get('window').width} imageHeight={Dimensions.get('window').height / 100 * 30} sourceUri={require('./images/image1.jpg')} placeholderSource={require('./images/placeholder.jpg')}>
25
- </KenBurnsImage>
26
- </View>
27
- <View style={styles.imageContainer}>
28
- <KenBurnsImage tension={6} friction={50} imageWidth={Dimensions.get('window').width} imageHeight={Dimensions.get('window').height / 100 * 30} sourceUri={require('./images/image2.jpg')} placeholderSource={require('./images/placeholder.jpg')}>
29
- </KenBurnsImage>
30
- </View>
31
- <View style={styles.imageContainer}>
32
- <KenBurnsImage tension={6} friction={50} imageWidth={Dimensions.get('window').width} imageHeight={Dimensions.get('window').height / 100 * 30} sourceUri={require('./images/image3.jpg')} placeholderSource={require('./images/placeholder.jpg')}>
33
- </KenBurnsImage>
34
- </View>
35
- </View>
36
- );
37
- }
38
- }
39
-
40
- const styles = StyleSheet.create({
41
- container: {
42
- flex: 1,
43
- justifyContent: 'center',
44
- alignItems: 'center',
45
- backgroundColor: '#F5FCFF',
46
- },
47
- title: {
48
- fontSize: 20,
49
- textAlign: 'center',
50
- margin: 10,
51
- },
52
- innerText: {
53
- textAlign: 'center',
54
- color: '#333333',
55
- marginBottom: 5,
56
- },
57
- imageContainer: {
58
- overflow: 'hidden',
59
- width: Dimensions.get('window').width,
60
- flexDirection: 'row',
61
- alignItems: 'center',
62
- justifyContent: 'center'
63
- },
64
- });
@@ -1,65 +0,0 @@
1
- # To learn about Buck see [Docs](https://buckbuild.com/).
2
- # To run your application with Buck:
3
- # - install Buck
4
- # - `npm start` - to start the packager
5
- # - `cd android`
6
- # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7
- # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8
- # - `buck install -r android/app` - compile, install and run application
9
- #
10
-
11
- lib_deps = []
12
-
13
- for jarfile in glob(['libs/*.jar']):
14
- name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15
- lib_deps.append(':' + name)
16
- prebuilt_jar(
17
- name = name,
18
- binary_jar = jarfile,
19
- )
20
-
21
- for aarfile in glob(['libs/*.aar']):
22
- name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23
- lib_deps.append(':' + name)
24
- android_prebuilt_aar(
25
- name = name,
26
- aar = aarfile,
27
- )
28
-
29
- android_library(
30
- name = "all-libs",
31
- exported_deps = lib_deps,
32
- )
33
-
34
- android_library(
35
- name = "app-code",
36
- srcs = glob([
37
- "src/main/java/**/*.java",
38
- ]),
39
- deps = [
40
- ":all-libs",
41
- ":build_config",
42
- ":res",
43
- ],
44
- )
45
-
46
- android_build_config(
47
- name = "build_config",
48
- package = "com.kenburnsexamplenew",
49
- )
50
-
51
- android_resource(
52
- name = "res",
53
- package = "com.kenburnsexamplenew",
54
- res = "src/main/res",
55
- )
56
-
57
- android_binary(
58
- name = "app",
59
- keystore = "//android/keystores:debug",
60
- manifest = "src/main/AndroidManifest.xml",
61
- package_type = "debug",
62
- deps = [
63
- ":app-code",
64
- ],
65
- )