Animating Images from scale 0 to 1
See original GitHub issueIssue Description
When using Animated.event
to map the user’s scroll position to the scale of an image, if the scroll position is such that the scale of the image is zero when the view is first rendered then the image will never be displayed.
Gifs speak a thousand words…
The yellow box error is complaining about fetch
,
Unable to symbolicate stack trace: fetch is not a function
Most likely because I am using Apollo Client, #9605
Steps to Reproduce / Code Snippets
constructor(props) {
super(props);
this.state = {
scrollY: new Animated.Value(SCROLL_MIN)
};
this.onScroll = Animated.event([{
nativeEvent: {
contentOffset: {
y: this.state.scrollY
}
}
}]);
}
renderAvatar() {
if(this.props.presentationStyle !== expanded) {
return null;
}
const props = {
style: [styles.avatar],
source: {
uri: this.state.business.avatar
}
};
const interpolate = {
inputRange: [SCROLL_MIN, SCROLL_MAX_AVATAR],
extrapolate: 'clamp'
};
const scale = this.state.scrollY.interpolate({
...interpolate,
outputRange: [1, 0]
});
const translateY = this.state.scrollY.interpolate({
...interpolate,
outputRange: [0, TRANSLATE_AVATAR_MAX]
});
props.style.push({
transform: [{translateY}, {scale}]
});
return <Animated.Image {...props} />
}
Expected Results
The image should scale from 0 to 1 when the initial scale is 0.
Additional Information
- React Native version:
0.35.0
- Platform(s) (iOS, Android, or both?): IOS
- Operating System (macOS, Linux, or Windows?): OSX
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Premiere Pro : How to Animate Increasing Image ... - YouTube
A tutorial on how to increase the image size with animation in Adobe ... This is also known as animating the scale. ......
Read more >Scaling Responsive Animations - CSS-Tricks
Guidelines for scaling responsive animations. 1. Size the animations based on a container ... .container { height: 0; padding-top: 100%; }.
Read more >Can I scale 1 image in animation to bigger and still maintain ...
Go to the start frame, select the image of the e.g. earth. Press "S" and scale it to the wanted start size. Now...
Read more >How do I use css transitions to scale an image and move it at ...
Codepen example: http://codepen.io/anon/pen/fipaL. Instead of top and left properties you shoud use translate3d CSS3 property, so to get ...
Read more >Animating CSS Width And Height Without The Squish Effect
This is called the 9-slice scaling method. Tis method allows you to scale the element and stretch image 2, 4, 6, and 8,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the meantime set the initial scale value to 0.01, that will force it to be rendered but is not big enough to be visible.
@Daniel-Goodwin you sir, has just saved my day!