GithubHelp home page GithubHelp logo

Comments (13)

Aljullu avatar Aljullu commented on May 13, 2024 2

@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.

asimoesmcartor avatar asimoesmcartor commented on May 13, 2024 1

@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 avatar Aljullu commented on May 13, 2024 1

@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.

Aljullu avatar Aljullu commented on May 13, 2024

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.

asimoesmcartor avatar asimoesmcartor commented on May 13, 2024

@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.

BilyachenkoOY avatar BilyachenkoOY commented on May 13, 2024

@Aljullu May I raise a PR with wrapperProps?

from react-lazy-load-image-component.

BilyachenkoOY avatar BilyachenkoOY commented on May 13, 2024

@Aljullu, yeah I missed #46. I think placeholderProps should be enough

from react-lazy-load-image-component.

johnstonbl01 avatar johnstonbl01 commented on May 13, 2024

@Aljullu 👋 Hey there! Would it be OK if I worked on the wrapperProps PR?

from react-lazy-load-image-component.

Aljullu avatar Aljullu commented on May 13, 2024

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.

johnstonbl01 avatar johnstonbl01 commented on May 13, 2024

Will do - thanks!

from react-lazy-load-image-component.

Aljullu avatar Aljullu commented on May 13, 2024

A beta version with the new wrapperProps prop is available in NPM. You can get it from:

Thanks @johnstonbl01 for the contribution.

from react-lazy-load-image-component.

JayBox325 avatar JayBox325 commented on May 13, 2024

@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.

Powerinno avatar Powerinno commented on May 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.