Skip to content

Commit

Permalink
Initial release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luehang committed Mar 21, 2019
0 parents commit b59ee65
Show file tree
Hide file tree
Showing 11 changed files with 7,509 additions and 0 deletions.
249 changes: 249 additions & 0 deletions .eslintrc.json

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Lue Hang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# react-native-easy-view-transformer

<a href="https://luehangs.site/marketplace/product/RN%20Posting%20Demo%20App%20Kit"><img src="https://luehangs.site/images/lh-mobile-strip.jpg" alt="LH LABS"/></a>
<br/>
<br/>

> An easy and simple to use React Native component to transform and translate a view.
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
17 changes: 17 additions & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/

module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
82 changes: 82 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"version": "1.0.0",
"name": "react-native-easy-view-transformer",
"description": "An easy and simple to use React Native component to transform and translate a view.",
"keywords": [
"react-native-easy-view-transformer",
"react-native",
"config",
"zoom in",
"zoom out",
"double tap",
"panning",
"over scroll distance",
"over scroll resistance",
"on pinch",
"on single tap",
"scaling",
"view",
"transform",
"translate",
"images",
"ios",
"android"
],
"homepage": "https://github.com/Luehang/react-native-easy-view-transformer",
"author": {
"name": "Lue Hang",
"email": "[email protected]",
"url": "https://www.luehangs.site"
},
"repository": {
"type": "git",
"url": "https://github.com/Luehang/react-native-easy-view-transformer"
},
"bugs": {
"url": "https://github.com/Luehang/react-native-easy-view-transformer/issues"
},
"directories": {
"src": "./src"
},
"main": "./src/index.js",
"files": [
"/src",
"LICENSE",
"package.json",
"README.md"
],
"dependencies": {
"prop-types": "^15.6.2",
"react-native-easy-guesture-responder": "^1.0.0",
"react-native-scrolling": "^1.0.0"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"devDependencies": {
"react": "16.8.3",
"react-native": "0.59.1",
"@babel/core": "^7.4.0",
"@babel/runtime": "^7.4.0",
"babel-jest": "^24.5.0",
"jest": "^24.5.0",
"metro-react-native-babel-preset": "^0.53.1",
"react-test-renderer": "16.8.3",
"babel-eslint": "^10.0.1",
"eslint": "^5.9.0",
"eslint-plugin-flowtype": "^3.2.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-react-native": "^3.5.0"
},
"jest": {
"preset": "react-native"
},
"scripts": {
"lint": "./node_modules/.bin/eslint src/",
"test": "jest"
},
"license": "MIT"
}
76 changes: 76 additions & 0 deletions src/Rect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
export default class Rect {
constructor (left, top, right, bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}

set (left, top, right, bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}

width () {
return this.right - this.left;
}

height () {
return this.bottom - this.top;
}

centerX () {
return (this.left + this.right) / 2;
}

centerY () {
return (this.top + this.bottom) / 2;
}

offset (dx, dy) {
this.left += dx;
this.right += dx;
this.top += dy;
this.bottom += dy;
return this;
}

copy () {
return new Rect(
this.left,
this.top,
this.right,
this.bottom
);
}

equals (rect, epsilon) {
if (!epsilon) {
return (
this.left === rect.left &&
this.top === rect.top &&
this.right === rect.right &&
this.bottom === rect.bottom
);
} else {
return (
Math.abs(this.left - rect.left) < epsilon &&
Math.abs(this.top - rect.top) < epsilon &&
Math.abs(this.right - rect.right) < epsilon &&
Math.abs(this.bottom - rect.bottom) < epsilon
);
}
}

isValid () {
if (typeof this.left === "number" &&
typeof this.right === "number" &&
typeof this.top === "number" &&
typeof this.bottom === "number") {
return true;
}
return false;
}
}
Loading

0 comments on commit b59ee65

Please sign in to comment.