react-native-draggable icon indicating copy to clipboard operation
react-native-draggable copied to clipboard

On dragging the animation having delay in android and it lags it's not smooth as IOS

Open Fardeen-N opened this issue 1 year ago • 0 comments

import React, { useEffect, useState } from 'react'; import { Alert, Dimensions, StyleSheet, Text, TouchableOpacity, ViewStyle } from 'react-native'; import Draggable from 'react-native-draggable'; import color from '../../constants/color'; import { regular } from '../../constants/globalstyle'; import { isGuestUser } from '../../utility/utils';

interface DraggablePlusButtonProps { onPress: () => void; style?: ViewStyle; }

const DraggablePlusButton: React.FC<DraggablePlusButtonProps> = ({ onPress, style }) => { const [dragging, setDragging] = useState(false); const [isAGuest, setSetIsAGuest] = useState(false);

useEffect(() => { isGuest() }, []);

async function isGuest(){ let isAGuest = await isGuestUser() setSetIsAGuest(isAGuest) } const handlePressIn = () => { setDragging(false); };

// Screen dimensions const screenWidth = Dimensions.get('screen').width; const screenHeight = Dimensions.get('screen').height;

// Button dimensions const buttonSize = 55; if(!isAGuest){ return null } return ( <Draggable x={screenWidth / 1.3} y={screenHeight / 1.45} minX={0} maxX={screenWidth - buttonSize} minY={0} maxY={screenHeight - buttonSize-screenHeight/5.5} onDragRelease={() => setDragging(false)} onDrag={() => setDragging(true)} > <TouchableOpacity style={[styles.button, style]} onPressIn={handlePressIn} onPress={onPress} activeOpacity={1} // Prevents opacity change during press > <Text style={styles.signInText}> {SignUp} </Text> </TouchableOpacity> </Draggable> ); };

const styles = StyleSheet.create({ button: { width: 55, height: 55, borderRadius: 55, backgroundColor: color.orange, opacity: 0.5, justifyContent: 'center', alignItems: 'center', position: 'absolute', }, plusContainer: { width: 20, height: 20, }, signInText: { fontSize: 12, fontFamily: regular, alignSelf: 'center', textAlign: 'center', color: color.white, } });

export default DraggablePlusButton;

The above is my code I am having issue of drag animation is lagging and it stop in android device it's not smooth as IOS

Can anyone help and give suggestion ?

Fardeen-N avatar Oct 01 '24 15:10 Fardeen-N