Skip to content

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

Description

@Fardeen-N

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 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions