diff options
author | Brian Kim <brian@tagg.id> | 2021-05-19 15:10:04 -0700 |
---|---|---|
committer | Brian Kim <brian@tagg.id> | 2021-05-19 15:10:04 -0700 |
commit | a8f095c734b748b38e2ac50483c41923ab0078f6 (patch) | |
tree | 4dd699cfaf240b2eafeb321203bb574c3df02c05 /src/screens/profile/CaptionScreen.tsx | |
parent | 0eda9c024f57b131263c8191903eb5d1d8c2aa57 (diff) |
Set middle placement
Diffstat (limited to 'src/screens/profile/CaptionScreen.tsx')
-rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 5adb27cb..309701b5 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -68,9 +68,12 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { // created a state variable to keep track of every tag // idea is that each element in the list const [taggList, setTaggList] = useState([]); - const draggableRef = useRef(null); const imageRef = useRef(null); const [tagInitCoords, setTagInitCoords] = useState([]); + const [offset, setOffset] = useState([0, 0]); + + const [curStart, setCurStart] = useState([0, 0]); + const [dim, setDim] = useState([0, 0]); const navigateToProfile = () => { //Since the logged In User is navigating to own profile, useXId is not required @@ -93,6 +96,8 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { console.log('Y offset to frame: ' + fy); console.log('X offset to page: ' + px); console.log('Y offset to page: ' + py); + setOffset([px, py]); + setDim([width, height]); }); }, []); @@ -157,9 +162,10 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { onChange={setCaption} partTypes={mentionPartTypes('blue')} /> - <Draggable x={207} y={(414 + 153) / 2}> + <Draggable + x={dim[0] / 2 - curStart[0] / 2 + offset[0]} + y={offset[1] + dim[1] / 2 - curStart[1] / 2}> <TaggDraggable - ref={draggableRef} draggable={true} minX={0} minY={0} @@ -168,6 +174,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { taggedUser={user} redirect={true} deleteFromList={() => console.log('Hello world')} + setStart={setCurStart} /> </Draggable> </View> |