You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to sync an animated 2 shared value with skia. This is my attempt so far. The animated 2 animation (non-skia) works perfectly, but the skia animation does not. If I change c={vec(progress.value, 72)} to c={vec(8 + ((width - 40) / 4) * selectedTabIndex, 72)} it works (albeit without any animation) so I believe my positioning calculations are correct, it's just not animating as I expect it to.
constBottomBarSkia=()=>{const{width}=useWindowDimensions();constcanvasRef=useRef();constprogress=useSharedValue(0);const[selectedTabIndex,setSelectedTabIndex]=useState(0);useDerivedValue(()=>{progress.value=withTiming(8+((width-40)/4)*selectedTabIndex,{duration: 1000,easing: Easing.bezier(0.25,0.1,0.25,1),});},[selectedTabIndex]);constanimatedStyle=useAnimatedStyle(()=>{return{left: progress.value,};});useSharedValueEffect(canvasRef,progress);constTabItem=({id, iconName, size =30})=>{return(<PressableonPress={()=>setSelectedTabIndex(id)}hitSlop={25}><Iconname={iconName}size={size}color={id===selectedTabIndex ? 'rgb(108, 228, 186)' : 'rgb(54,100,83)'}/></Pressable>);};return(<><Canvasref={canvasRef}style={{position: 'absolute',left: 20,width: width-40,height: 72}}><Paintstyle="stroke"strokeWidth={2}><RadialGradientc={vec(progress.value,72)}r={128}colors={['rgb(108,228,186)','rgb(54,100,83)']}/></Paint><RoundedRectrx={20}x={0}y={0}width={width-40}height={72}/></Canvas><Viewstyle={{flex: 1,borderRadius: RADIUS,overflow: 'hidden',margin: 1,}}><Animated.Viewstyle={[{position: 'absolute',bottom: 0,backgroundColor: 'rgb(108,228,186)',// calculate the width of the bar to glow// width minus 40 (20 padding each side)// divided by number of tabs// minus 15 which is our offset from the left edgewidth: (width-40)/4-15,height: 12,borderTopLeftRadius: 15,borderTopRightRadius: 15,},animatedStyle,]}/><BlurViewblurType={'dark'}blurAmount={50}reducedTransparencyFallbackColor="rgba(37,42,54,.25)"style={{flex: 1,flexDirection: 'row',justifyContent: 'space-around',alignItems: 'center',}}><TabItemid={0}iconName="ios-bar-chart-outline"/><TabItemid={1}iconName="ios-card-outline"/><TabItemid={2}iconName="ios-notifications-outline"/><TabItemid={3}iconName="ios-apps-outline"/></BlurView></View></>);};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am attempting to sync an animated 2 shared value with skia. This is my attempt so far. The animated 2 animation (non-skia) works perfectly, but the skia animation does not. If I change
c={vec(progress.value, 72)}
toc={vec(8 + ((width - 40) / 4) * selectedTabIndex, 72)}
it works (albeit without any animation) so I believe my positioning calculations are correct, it's just not animating as I expect it to.Beta Was this translation helpful? Give feedback.
All reactions