aboutsummaryrefslogtreecommitdiff
path: root/src/components/taggs/TaggDraggable.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-05-26 18:19:23 -0400
committerIvan Chen <ivan@tagg.id>2021-05-26 18:19:23 -0400
commit2fa874efdc5d1b2a1cd508c46ddcc6e2e7511157 (patch)
tree5a33cea2fb4c8698e4514ca58027ec5da4dd92b5 /src/components/taggs/TaggDraggable.tsx
parent716caad656f8435f93a33596692e7e83f0a2af12 (diff)
Cleanup draggable, Pass ref to each draggable
Diffstat (limited to 'src/components/taggs/TaggDraggable.tsx')
-rw-r--r--src/components/taggs/TaggDraggable.tsx34
1 files changed, 3 insertions, 31 deletions
diff --git a/src/components/taggs/TaggDraggable.tsx b/src/components/taggs/TaggDraggable.tsx
index e964d3d1..06825641 100644
--- a/src/components/taggs/TaggDraggable.tsx
+++ b/src/components/taggs/TaggDraggable.tsx
@@ -1,5 +1,5 @@
import {useNavigation} from '@react-navigation/native';
-import React, {useRef} from 'react';
+import React from 'react';
import {
Image,
StyleSheet,
@@ -17,12 +17,10 @@ import {normalize} from '../../utils';
import {navigateToProfile} from '../../utils/users';
interface TaggDraggableProps extends ViewProps {
+ draggableRef: React.MutableRefObject<null>;
taggedUser: ProfilePreviewType;
editingView: boolean;
deleteFromList: () => void;
- setStart: Function;
- offset: {fx: number; fy: number};
- imageDimensions: {width: number; height: number};
}
const TaggDraggable: React.FC<TaggDraggableProps> = (
@@ -31,36 +29,10 @@ const TaggDraggable: React.FC<TaggDraggableProps> = (
const navigation = useNavigation();
const dispatch = useDispatch();
const state = useSelector((rs: RootState) => rs);
- const {
- taggedUser,
- editingView,
- deleteFromList,
- setStart,
- offset,
- imageDimensions,
- } = props;
+ const {draggableRef, taggedUser, editingView, deleteFromList} = props;
let uriX = require('../../assets/images/draggableX.png');
let uriTip = require('../../assets/images/Tagg-Triangle.png');
- const draggableRef = useRef(null);
-
- const getPositions = () =>
- draggableRef.current.measure(
- (
- _fx: number, // location of ref relative to parent element
- _fy: number,
- _width: number,
- _height: number,
- px: number, // location of ref relative to entire screen
- py: number,
- ) => {
- return [
- Math.floor(((px - offset.fx) / imageDimensions.width) * 100),
- Math.floor(((py - offset.fy) / imageDimensions.height) * 100),
- ];
- },
- );
-
const user: UserType = {
userId: taggedUser.id,
username: taggedUser.username,