-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support aspect ratio for components (#244)
* Support aspect ratio for components Jasonette/documentation#62 * More ways of expressing ratio (ex: 2:1,1/3) * Support ratio for layers * Remove image prefetching to optimize loading ## Solution DO NOT prefetch if: 1. height is fixed 2. width and ratio are specified ## What problem it solves Previously ALL images were prefetched because that was the only way to estimate the height, which is how Jasonette constructs the layout in a robust manner. This mostly works and does what it's designed to do, but with a side effect: Since it prefetches EVERY image on the screen, say if you had 2000 images, the view would start prefetching ALL of these images immediately upon load, even those that are not immediately visible because they're outside the viewport. This means you have 2000 concurrent network requests open just for these images. Normally a view doesn't contain that many images and it works just fine as is, but when we have a lot of images it can congest up the network, sometimes even resulting in a delayed load of the images that DO need to load immediately. For example the images in the currently visible viewport need to be loaded as soon as possible, but with prefetching this becomes non-deterministic, especially when there are a lot of images. This is why sometimes it feels like an image is loading forever when you open the app. ## Effect This should have an immediate effect if your view contains a lot of images. More specifically image loading should feel visibly faster (because there's no prefetch and it only loads the images that need to be loaded on-demand) To get this to work, you need to either set: 1. style.height 2. style.width AND style.ratio
- Loading branch information
1 parent
5b5c577
commit ad3369a
Showing
6 changed files
with
92 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters