Comments (13)
@asimoesmcartor the display: inline-block
is required to make the placeholder visible. The placeholder is a <span>
with a background image but no content, so it needs to be a block to have height
and width
. I used inline-block
instead of block
to replicate better the default behavior of images, which are inline
according to browser default styles.
I'm considering to add a placeholderProps
or wrapperProps
prop so the style and other attributes can be overwritten. I guess that would be good enough to solve your issues here.
In the short term, you can set:
.lazy-load-image-background {
display: block !important;
}
in your CSS and that would overwrite the default display
value set by the library.
from react-lazy-load-image-component.
@Aljullu Ahh perfect. Thank you so much! I will use the workaround for now. I think I was just missing the "!important" part and it was blocking me. Still learning over here!
I'll keep an eye on this issue just in case you decide to pass the placeholder and wrapper props. Thanks again!
from react-lazy-load-image-component.
@Aljullu May I raise a PR with wrapperProps?
Sure, that would be awesome! There is a WIP PR about adding loadedImageProps
and placeholderProps
which might be useful to use as a reference: #46.
You can even use the add/loaded-image-props
branch as a base if you want. master
would be fine as well.
from react-lazy-load-image-component.
Perhaps the style for the wrapper should be defined in the CSS of each effect instead.
This would be a good solution, the only issue I see is that the wrapper element is also used when placeholderSrc
is defined, even if there is no effect. So we would need to create a new CSS file and ideally only import it if the wrapper element is displayed.
Thanks for filling this issue @elamperti, will mark it as enhancement
in case I have time in the future or somebody is willing to pick it up!
from react-lazy-load-image-component.
@Aljullu I am also running into a similar issue caused by the pre-defined styles in the LazyLoadImage.jsx file on line 77.
Is there any way that you could remove the "display:inline-block" style in that span?
Or could you give more context on why you added this style?
from react-lazy-load-image-component.
@Aljullu May I raise a PR with wrapperProps
?
from react-lazy-load-image-component.
@Aljullu, yeah I missed #46. I think placeholderProps
should be enough
from react-lazy-load-image-component.
@Aljullu 👋 Hey there! Would it be OK if I worked on the wrapperProps
PR?
from react-lazy-load-image-component.
Sure thing @johnstonbl01! I'm happy to review any new PRs that are pushed to the repo. Make sure to take a look at #46 in case you think that might be good enough for your use-case. Otherwise maybe it's a good base to start from. It has got big conflicts but I think it's just formatting (spaces → tabs).
from react-lazy-load-image-component.
Will do - thanks!
from react-lazy-load-image-component.
A beta version with the new wrapperProps
prop is available in NPM. You can get it from:
$ npm i [email protected]
Thanks @johnstonbl01 for the contribution.
from react-lazy-load-image-component.
@Aljullu Thanks for adding this, can you please add an example to the docs for how to use the wrapperProps object as I haven't been able to get it working with different tries. Thanks
from react-lazy-load-image-component.
It still has an inline-block display but, it is not in a CSS class, is inline style. Can anyone show me how could I remove it? https://github.com/Aljullu/react-lazy-load-image-component/blob/master/src/components/LazyLoadImage.jsx - line 115
from react-lazy-load-image-component.
Related Issues (20)
- Warning: Prop style did not match.
- Image is not rendring on big screes ie: above 2500px resolution device.
- Either strPlaceholder doesn't work or I'm doing it wrong...please help.
- It renders span tag instead of image tag HOT 3
- While installing I am getting "unable to resolve dependency tree" error HOT 1
- If Img Fallback Is Error? HOT 1
- .blur and TailWind's .blur duplicate name HOT 1
- Error when test rendering component using React Test Library HOT 2
- Can't use with TypeScript
- IntersectionObserver.unobserve: Argument 1 is not an object.
- How to remove placeholder only when image fully loaded? HOT 2
- Images keep loading even image is not part of the DOM anymore (Switching pages/views)
- Use the `next/image` HOT 3
- Image shrinks when using placeHolderSrc or effect HOT 1
- Named export 'LazyLoadImage' not found. The requested module 'react-lazy-load-image-component' is a CommonJS module, which may not support all module.exports as named expo rts. HOT 13
- Lazy load isn't working? HOT 3
- Issue with lazy load component, ssr
- blur effect on rounded image shows rectangle blur, the blur is in rectangle and overflows the container div
- LazyLoadComponent's placeholder is visible even when the image is in viewport.
- react-lazy-load-image-component image render a half part of image 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-lazy-load-image-component.