Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Fardeen-N opened this issue Oct 1, 2024 · 0 comments

Comments

@Fardeen-N
Copy link

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 = ({ 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
>

{SignUp}



);
};

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 Fardeen-N changed the title drag the animation having delay in android and it lags On dragging the animation having delay in android and it lags it's not smooth as IOS Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant