Comments (10)
@jossmac is this enhancement for preloading of the larger lightbox images or the gallery preview images?
from react-images.
@neptunian the larger lightbox images. The idea was to implement this with a Boolean
prop preloadImages
.
The idea was to loop over the images array and preload using new Image()
. I have a working example in a commercial project where I've forked this component. Is it something you'd be interested in?
from react-images.
@neptunian it's worth mentioning that this component doesn't know about, and has no need for, the preview thumbnails. That can be handled elsewhere π
from react-images.
@jossmac right, just makin' sure ;) Just had someone open an issue in my gallery component about it (neptunian/react-photo-gallery#3). If you've got a working solution for it, be my guest! :)
from react-images.
@jossmac i'd be interested in doing this if you'd like to show me the working example you had in mind.
from react-images.
@neptunian thanks for the offer. I'd like to sort it out though
from react-images.
@jossmac sounds good.
from react-images.
Started using react-images and it fits my use case perfectly (keep control over the gallery, and use something else for the lightbox part). Preloading would be a huge plus for me as well.
Has anyone tried just rendering the previous and next images in a 0 width div and let the browser do the preloading ?
Something like
renderPreloadImage(extraIndex) {
const { images, currentImage } = this.props;
const idx = currentImage + extraIndex
if (!images || !images.length || idx < 0 || idx >= images.length) return null;
const image = images[currentImage];
let srcset;
let sizes;
if (image.srcset) {
srcset = image.srcset.join();
sizes = '100vw';
}
return (
<img style={{
width: 0, height: 0
}}
sizes={sizes}
src={image.src}
srcSet={srcset}
/>
);
}
Used as
<div className={classes.content}>
{this.renderCloseBar()}
{this.renderImages()}
{this.state.isLoaded && this.renderPreloadImage(-1)}
{this.state.isLoaded && this.renderPreloadImage(1)}
</div>
(this.state.isLoaded could be used to keep track of if the current image is already loaded, to only preload once the image itself is loaded)
from react-images.
That's an interesting thought @GregoryPotdevin thanks for sharing. I have a plan for this that I'd really like to try out
I'm sorry for dropping this for so long, but I will pick it up and add it to my list for this week.
from react-images.
Great !
Another way to do it that would work with custom components (and not just image links) would be to render the normal previous/next but inside a hidden div. But I'm not sure how and when the different browsers preload images in hidden divs. A clean implementation with this idea could also provide scrolling animations when changing currentImage.
from react-images.
Related Issues (20)
- showNavigationOnTouchDevice is not part of the type for CarouselProps HOT 2
- Style Autoprefixer broken for `display: flex`
- TypeError: undefined is not an object (evaluating 'currentView.caption') HOT 1
- Option to always show header and footer. HOT 1
- Warning using ModalGateway in react's Strict Mode HOT 2
- Is there a way to disable some/all the shortcuts ? HOT 1
- Component Customization with Styled-Components Library HOT 5
- Picture title HOT 4
- NPM Audit Security report HOT 3
- ζ³ζ·»ε δΈδΈͺζ₯ηι’θ§εΎζΆοΌε―ζ转ηεθ½
- React 17 support HOT 6
- FATAL: 1.1.7 to 1.2.0-beta.6 breaks fullscreen mode ('active' of undefined) HOT 7
- is there a way we can disable scrolling for the carousel
- Demo error HOT 4
- In search of a replacement β HOT 2
- Can I get the images data from a json file and how? Thanks HOT 1
- Can you add an option for adding hyperlink(s) under the photo? HOT 1
- A vulnerability introduced in react-images HOT 2
- Can it view .tif or .tiff type image ? HOT 1
- Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes'. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-images.