question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Image] Resizing image with Animation (with resizeMode="cover") is glitchy

See original GitHub issue

You can see the issue here:

Image of issue

Video of Issue (if gif is not clear): http://s.sk3vy.com/cCZ0

(you can see that it glitches a little bit as it resizes)

Code-wise, all I’m doing is doing:

Animated.parallel([
  Animated.spring(
    this.state.imageOverlay.position, {
      toValue: { x: 0, y: 0 },
      friction: 20,
      tension: 220
  }),
  Animated.spring(
    this.state.imageOverlay.size, {
      toValue: { x: this.screenWidth, y: this.screenHeight },
      friction: 20,
      tension: 220
  })
]).start();

Nothing out of the ordinary there.

In debugging this issue…it seems it may have something to do with this:

https://github.com/facebook/react-native/blob/757d6d204ae2d743634af64e3f78a4aad9d53f70/Libraries/Image/RCTImageView.m#L174-L176

When I don’t reload the image (comment out line 175), it’s smooth as butter, as you might expect. Obviously that’s not a solution here, but I think it does give insight into the problem.

It seems like it would be good to somehow (perhaps optionally) defer the reloading and resampling of the image until after an animation has completed.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
idecommented, Aug 27, 2015

awesometown population: nicklockwood

0reactions
skevycommented, Aug 27, 2015

@nicklockwood new code works flawlessly with my use-case. It’ll make it into the next app store update. Thanks! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding “resizeMode” in React Native | by Mehran Khan
There are different options in Image “reiszeMode” ('cover', 'contain', 'stretch', 'repeat', 'center'). It can be tricky which one to use if you does...
Read more >
How to force an image to be full width and maintain aspect ...
My use was very similar in that I needed to display an image with full screen width but maintaining its aspect ratio. Based...
Read more >
Resize image proportionally with CSS - GeeksforGeeks
The resize image property is used in responsive web where image is resizing automatically to fit the div container.
Read more >
object-fit - CSS: Cascading Style Sheets - MDN Web Docs
object-fit: scale-down; ... cover. The replaced content is sized to maintain its aspect ratio while ... Setting object-fit for an image ...
Read more >
react-native-fast-image - npm
FastImage, performant React Native image component. ... resizeMode.cover (Default) - Scale the image uniformly (maintain the image's aspect ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found