By the title I mean that when I click on the animation nothing happens. But when I click slightly to the left of it, it works.
Here is my code:
<View style={{flex: 1, alignItems:'center', right: 0, left: 0, flexDirection:'row', position: 'absolute', alignSelf:'center', top: 10}}>
{this.state.queryid.includes(item.id) ?
<TouchableOpacity
ref="unlikeButton"
onPress={() => this.anim_unlike(item)}
style={{ zIndex: 1, }}
hitSlop={{ top: 20, left: 20, bottom: 20, right: 100 }}>
<Animation
progress={item.unprogress}
source={require('../Animations/favourite_app_icon.json')}
style={{ height: 50, width: 50, alignSelf:'center', marginLeft: 0, left: 5}}
resizeMode={`contain`}
/>
</TouchableOpacity>
:
<TouchableOpacity
ref="likeButton"
onPress={() => this.anim_like(item)}
style={{zIndex: 1, }}
hitSlop={{ top: 20, left: 20, bottom: 20, right: 100 }}>
<Animation
progress={item.progress}
source={require('../Animations/favourite_app_icon.json')}
style={{ height: 50, width: 50, alignSelf:'center', marginLeft: 0, left: 5}}
resizeMode={`contain`}
/>
</TouchableOpacity>
}
<Text style={{alignSelf:'center', color: 'black', fontFamily: Fonts.QuoFont, fontSize: 15}}>{item.likes}</Text>
</View>
Where you see hitSlop
that is where I try to widen the touch box, but that's not working at all. And when I take away position: absolute
from the View the touchable area correctly functions in it's proper area, in the star. I need it absolute so that the rest of my elements can stay in the right place. It would be great if there was something that can make view behave like absolute where it would not interfere with other elements.