Replies: 1 comment
-
Hey @oiver555! I am very sorry for the late response. Indeed, I was able to reproduce the problem and it looks like you described. We will have to look for a valid solution on our side and fix the issue in the library itself but I can provide you a workaround. WorkaroundBetter solution (New Architecture only)You can add just one layout prop to the animated style passed to the This is the modified animated style: const rSelectedWordStyle = useAnimatedStyle(() => {
return {
backgroundColor: interpolateColor(
selectSwitch.value,
[0, 1],
['transparent', 'rgba(246,128,252,1)'],
),
// Add this prop (can be also other layout prop that has no effect on the
// text layout like `left` / `right` / `bottom`/ etc.)
top: selectSwitch.value,
};
}, []); Worse solution (Old & New Architectures)Instead of wrapping your word ExplanationReanimated uses 2 different ways to update style properties:
For some reason, when you nest Hope it helps. Let me know if you have more questions. |
Beta Was this translation helpful? Give feedback.
-
When I try to do a interpolate on the backgroundColor of a Text component, it doesn't work. My code looks something like this...
A lot of things have been abstracted away, but basically, When a user selects two words in my
<TextSelect />
it will select all the words in between those 2 selected words. I thought it would be nice to have the highlight effect be gradual versus abrupt, and here is where the issue lies.My setup may look complicated, but if you go ahead and just try to interpolateColor the backgroundColor of a
<Text/>
I'm sure you will see a problem.Now, You may say, just wrap the
<TextSelectWord/>
component in a<View/>
and animate the background color on the<View/>
instead. That does work, however, wrapping each of my<TextSelectWord/>
components in a<View/>
alters the flow of text in other words my paragraph which has the textAlign set to justify, Will no longer be justified because the<View/>s
are negating that from happening. This is why I want to animate the background color on the<Text/>
components directly so that I can maintain the textAlign justified setting.Beta Was this translation helpful? Give feedback.
All reactions