├── Example ├── .watchmanconfig ├── .gitattributes ├── .babelrc ├── app.json ├── android │ ├── settings.gradle │ ├── app │ │ ├── src │ │ │ └── main │ │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ ├── proguard-rules.pro │ │ ├── BUCK │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── keystores │ │ ├── debug.keystore.properties │ │ └── BUCK │ ├── gradle.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── assets │ ├── coin.png │ └── star.png ├── .prettierrc ├── ios │ ├── Example │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── AppDelegate.m │ │ ├── Info.plist │ │ └── Base.lproj │ │ │ └── LaunchScreen.xib │ ├── ExampleTests │ │ ├── Info.plist │ │ └── ExampleTests.m │ ├── Example-tvOSTests │ │ └── Info.plist │ ├── Example-tvOS │ │ └── Info.plist │ └── Example.xcodeproj │ │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── Example.xcscheme │ │ │ └── Example-tvOS.xcscheme │ │ └── project.pbxproj ├── screenshosts │ └── particles.gif ├── .buckconfig ├── index.js ├── package.json ├── .gitignore ├── animations │ └── Spin.js ├── App.js ├── examples │ ├── CoinsExplosion.js │ ├── StarsToTarget.js │ └── Confetti.js └── .flowconfig ├── .babelrc ├── .gitignore ├── .npmignore ├── .prettierrc ├── __tests__ ├── __snapshots__ │ ├── Emitter.spec.js.snap │ └── BustAndMoveEmitter.spec.js.snap ├── BustAndMoveEmitter.spec.js └── Emitter.spec.js ├── entities ├── Vector.js └── Particle.js ├── index.js ├── .flowconfig ├── utils ├── move-particle.js ├── __tests__ │ ├── emit-particle.spec.js │ ├── move-particle.spec.js │ └── vector-helpers.spec.js ├── vector-helpers.js └── emit-particle.js ├── package.json ├── README.md ├── AnimatedParticle.js ├── Emitter.js ├── BurstAndMoveEmitter.js └── BaseEmitter.js /Example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } 4 | -------------------------------------------------------------------------------- /Example/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | coverage 4 | 5 | yarn-error.log 6 | .DS_Store -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | Example 3 | coverage 4 | README.md 5 | .babelrc 6 | .prettierrc -------------------------------------------------------------------------------- /Example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Example", 3 | "displayName": "Example" 4 | } -------------------------------------------------------------------------------- /Example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Example' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /Example/assets/coin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/assets/coin.png -------------------------------------------------------------------------------- /Example/assets/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/assets/star.png -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "singleQuote": true, 5 | "trailingComma": "none" 6 | } 7 | -------------------------------------------------------------------------------- /Example/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "singleQuote": true, 5 | "trailingComma": "none" 6 | } 7 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example 3 | 4 | -------------------------------------------------------------------------------- /Example/ios/Example/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/screenshosts/particles.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/screenshosts/particles.gif -------------------------------------------------------------------------------- /Example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /Example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Example/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /__tests__/__snapshots__/Emitter.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Emitter should consider child prop as a particle 1`] = `null`; 4 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /__tests__/__snapshots__/BustAndMoveEmitter.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`BostAndMoveEmitter should consider child prop as a particle 1`] = `null`; 4 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanndoj/react-native-particles/HEAD/Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /entities/Vector.js: -------------------------------------------------------------------------------- 1 | //@flow 2 | export type VectorType = { 3 | x: number, 4 | y: number 5 | }; 6 | 7 | // Constructor helper 8 | export const Vector = (x: number = 0, y: number = 0): VectorType => ({ x, y }); 9 | -------------------------------------------------------------------------------- /Example/index.js: -------------------------------------------------------------------------------- 1 | /** @format */ 2 | 3 | import { AppRegistry } from 'react-native'; 4 | import App from './App'; 5 | import { name as appName } from './app.json'; 6 | 7 | AppRegistry.registerComponent(appName, () => App); 8 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | //@flow 2 | export { default as Emitter } from './Emitter'; 3 | export { default as BurstAndMoveEmitter } from './BurstAndMoveEmitter'; 4 | 5 | export { Vector } from './entities/Vector'; 6 | export type { VectorType } from './entities/Vector'; 7 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip 6 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; Ignore metro 3 | .*/node_modules/.* 4 | 5 | [include] 6 | 7 | [libs] 8 | node_modules/react-native/Libraries/react-native/react-native-interface.js 9 | node_modules/react-native/flow/ 10 | node_modules/react-native/flow-github/ 11 | 12 | [options] 13 | emoji=true 14 | 15 | module.system=haste 16 | module.system.haste.use_name_reducers=true 17 | 18 | [version] 19 | ^0.75.0 20 | -------------------------------------------------------------------------------- /Example/ios/Example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (nonatomic, strong) UIWindow *window; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Example/ios/Example/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/android/app/src/main/java/com/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "Example"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /entities/Particle.js: -------------------------------------------------------------------------------- 1 | //@flow 2 | import { Vector } from './Vector'; 3 | import type { VectorType } from './Vector'; 4 | 5 | export type ParticleType = { 6 | position: VectorType, 7 | velocity: VectorType, 8 | acceleration: VectorType, 9 | id: number 10 | }; 11 | 12 | export const Particle = ( 13 | velocity: VectorType = Vector(0, 0), 14 | acceleration: VectorType = Vector(0, 0), 15 | id: number, 16 | position?: VectorType = Vector(0, 0) 17 | ): ParticleType => ({ 18 | position, 19 | velocity, 20 | acceleration, 21 | id 22 | }); 23 | -------------------------------------------------------------------------------- /utils/move-particle.js: -------------------------------------------------------------------------------- 1 | //@flow 2 | import { Particle } from './../entities/Particle'; 3 | import { add } from './vector-helpers'; 4 | 5 | import type { ParticleType } from './../entities/Particle'; 6 | 7 | export const move = (particle: ParticleType): ParticleType => { 8 | // Calculate the velocity by adding acceleration 9 | const velocity = add(particle.velocity, particle.acceleration); 10 | 11 | // Calculate the new position 12 | const position = add(particle.position, velocity); 13 | 14 | return Particle(velocity, particle.acceleration, particle.id, position); 15 | }; 16 | 17 | export default Particle; 18 | -------------------------------------------------------------------------------- /Example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "16.4.1", 11 | "react-native": "0.56.0", 12 | "react-native-particles": "nanndoj/react-native-particles#master" 13 | }, 14 | "devDependencies": { 15 | "babel-jest": "23.4.2", 16 | "babel-preset-react-native": "^5", 17 | "jest": "23.4.2", 18 | "react-test-renderer": "16.4.1" 19 | }, 20 | "jest": { 21 | "preset": "react-native" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Example/ios/Example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/ios/ExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/ios/Example-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /utils/__tests__/emit-particle.spec.js: -------------------------------------------------------------------------------- 1 | //@flow 2 | 3 | import emitParticle from '../emit-particle'; 4 | import { Vector } from '../../entities/Vector'; 5 | 6 | describe('Emit Particles', () => { 7 | it('should emmit new particles', () => { 8 | const particle = emitParticle( 9 | Vector(0, 0), // Initial position 10 | Vector(2, 2), // Velocity 11 | null, // Spread angle (in radians) 12 | Vector(1, 1), // Acceleration 13 | 1 // Unique particle id 14 | ); 15 | expect(particle).toBeTruthy(); 16 | }); 17 | 18 | it('The particle velocity should be randomized along the spread angle ', () => { 19 | const velocity = Vector(2, 2); 20 | 21 | const particle = emitParticle( 22 | Vector(0, 0), // Initial position 23 | velocity, // Velocity 24 | 1.2, // Spread angle (in radians) 25 | Vector(1, 1), // Acceleration 26 | 1 // Unique particle id 27 | ); 28 | expect(particle.velocity).not.toEqual(velocity); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /utils/vector-helpers.js: -------------------------------------------------------------------------------- 1 | // Gets the length of the vector 2 | import { Vector } from './../entities/Vector'; 3 | import type { VectorType } from './../entities/Vector'; 4 | 5 | export const getMagnitude = (vector: VectorType): number => 6 | Math.sqrt(vector.x * vector.x + vector.y * vector.y); 7 | 8 | // Add a vector to another 9 | export const add = (vectorA: VectorType, vectorB: VectorType): VectorType => 10 | Vector(vectorA.x + vectorB.x, vectorA.y + vectorB.y); 11 | 12 | // Gets the angle accounting for the quadrant we're in 13 | export const getAngle = (vector: VectorType): number => 14 | Math.atan2(vector.y, vector.x); 15 | 16 | // Allows us to get a new vector from angle and magnitude 17 | export const fromAngle = (angle: number, magnitude: number): VectorType => 18 | Vector(magnitude * Math.cos(angle), magnitude * Math.sin(angle)); 19 | 20 | export const toRadians = (angle: number): number => angle * (Math.PI / 180); 21 | export const toDegrees = (radians: number): number => (radians * 180) / Math.PI; 22 | -------------------------------------------------------------------------------- /Example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | -------------------------------------------------------------------------------- /utils/emit-particle.js: -------------------------------------------------------------------------------- 1 | //@flow 2 | import { fromAngle, getAngle, getMagnitude } from './vector-helpers'; 3 | import { Particle } from './../entities/Particle'; 4 | 5 | import type { VectorType } from './../entities/Vector'; 6 | import type { ParticleType } from './../entities/Particle'; 7 | 8 | const emitParticle = function( 9 | initPosition: VectorType, 10 | velocity: VectorType, 11 | spread: number = Math.PI / 32, 12 | acceleration: VectorType, 13 | id: number 14 | ): ParticleType { 15 | // Use an angle randomized over the spread so we have more of a "spray" 16 | const angle = getAngle(velocity) + spread - Math.random() * spread * 2; 17 | 18 | // The magnitude of the emitter's velocity 19 | const magnitude = getMagnitude(velocity); 20 | 21 | // New velocity based off of the calculated angle and magnitude 22 | const newVelocity = fromAngle(angle, magnitude); 23 | 24 | // return our new Particle in the initialPosition without acceleration 25 | return Particle(newVelocity, acceleration, id, initPosition); 26 | }; 27 | 28 | export default emitParticle; 29 | -------------------------------------------------------------------------------- /Example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | maven { 7 | url 'https://maven.google.com/' 8 | name 'Google' 9 | } 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:2.3.3' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | mavenLocal() 22 | jcenter() 23 | maven { 24 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 25 | url "$rootDir/../node_modules/react-native/android" 26 | } 27 | maven { 28 | url 'https://maven.google.com/' 29 | name 'Google' 30 | } 31 | } 32 | } 33 | 34 | ext { 35 | buildToolsVersion = "26.0.3" 36 | minSdkVersion = 16 37 | compileSdkVersion = 26 38 | targetSdkVersion = 26 39 | supportLibVersion = "26.1.0" 40 | } 41 | -------------------------------------------------------------------------------- /Example/android/app/src/main/java/com/example/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.shell.MainReactPackage; 9 | import com.facebook.soloader.SoLoader; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | return Arrays.asList( 25 | new MainReactPackage() 26 | ); 27 | } 28 | 29 | @Override 30 | protected String getJSMainModuleName() { 31 | return "index"; 32 | } 33 | }; 34 | 35 | @Override 36 | public ReactNativeHost getReactNativeHost() { 37 | return mReactNativeHost; 38 | } 39 | 40 | @Override 41 | public void onCreate() { 42 | super.onCreate(); 43 | SoLoader.init(this, /* native exopackage */ false); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Example/animations/Spin.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { StyleSheet, Animated, Easing } from 'react-native'; 3 | 4 | export default class Spin extends Component { 5 | constructor(props) { 6 | super(props); 7 | this.state = { 8 | animatedValue: new Animated.Value(0) 9 | }; 10 | } 11 | render() { 12 | const { children, counterClockWise } = this.props; 13 | return ( 14 | 28 | {children} 29 | 30 | ); 31 | } 32 | 33 | componentDidMount() { 34 | const { animatedValue } = this.state; 35 | Animated.loop( 36 | Animated.sequence([ 37 | Animated.timing(animatedValue, { 38 | toValue: 1, 39 | duration: this.props.duration, 40 | useNativeDriver: true 41 | }), 42 | Animated.timing(animatedValue, { 43 | toValue: 0, 44 | duration: 0, 45 | useNativeDriver: true 46 | }) 47 | ]) 48 | ).start(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Example/ios/Example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | 13 | @implementation AppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | NSURL *jsCodeLocation; 18 | 19 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 20 | 21 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 22 | moduleName:@"Example" 23 | initialProperties:nil 24 | launchOptions:launchOptions]; 25 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 26 | 27 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 28 | UIViewController *rootViewController = [UIViewController new]; 29 | rootViewController.view = rootView; 30 | self.window.rootViewController = rootViewController; 31 | [self.window makeKeyAndVisible]; 32 | return YES; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Example/App.js: -------------------------------------------------------------------------------- 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 { Button, StyleSheet, View } from 'react-native'; 11 | 12 | import CoinsExplosion from './examples/CoinsExplosion'; 13 | import Confetti from './examples/Confetti'; 14 | import StarsToTarget from './examples/StarsToTarget'; 15 | 16 | type Props = {}; 17 | export default class App extends Component { 18 | render() { 19 | return ( 20 | 21 |