-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
object
support?
#177
Comments
Hi @zvaehn, To better understand your request, could you post here the snippet of HTML code you would use? Thanks |
<object type="image/svg+xml" data="image.svg"></object>
|
That would make sense, but I never saw an SVG used like that. Are you sure it works? I tried it on this Pen, both with the <object type="image/svg+xml" src="http://simpleicon.com/wp-content/uploads/mail-5.svg"></object> On the other hand, the svg file as source of an <img src="http://simpleicon.com/wp-content/uploads/mail-5.svg" alt="mail"></img> So why don't use the img tag to lazily load SVGs too? |
I think there is an issue with the svg you are using. The object-tag is more flexible than the img-tag. If you are using the img-tag, the font cannot be loaded. |
It probably was a mixed-content issue, due to the fact that codepen is on https and the image was your |
...was on http. Thanks for fixing that. |
Still here. |
Hi @zvaehn, I'm not quite sure this is in-scope for the LazyLoad project. Adding another meta data attribute would add too much code just to handle a small percentage of the use cases. Maybe try doing a pull request if you have an idea. Thank you for your patience. |
Hello guys. Just found this and checked that vanilla-lazyload is still not being able to work with the |
Hi @matheusdigital |
I understand your request now @matheusdigital So you would like something like this: <object type="image/svg+xml"
class="lazy"
data-data="https://greensock.com/wp-content/themes/greensock/images/icon-github.svg">
</object> To become the following when it enters the viewport <object type="image/svg+xml"
class="lazy entered"
data="https://greensock.com/wp-content/themes/greensock/images/icon-github.svg">
</object> Is that correct? |
@verlok Exactly! I managed how to get that with the following JS code. But I guess you could implement something similar onto your lib :) <object
class="scroll-reveal-animation"
type="image/svg+xml"
data-object="https://greensock.com/wp-content/themes/greensock/images/icon-github.svg">
</object>` function scrollTrigger(selector) {
let elementsFound = document.querySelectorAll(selector)
elementsFound = Array.from(elementsFound)
elementsFound.forEach(domElement => {
addObserver(domElement)
})
}
function addObserver(domElement) {
let observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('active')
var svgObject = entry.target.getAttribute('data-object');
if (svgObject) {
entry.target.setAttribute('data', svgObject);
}
observer.unobserve(entry.target)
}
})
})
observer.observe(domElement)
}
document.addEventListener('DOMContentLoaded', () => {
scrollTrigger('.scroll-reveal-animation');
}); Thanks! |
(I edited your comment above, if you edit it again you will see how to format code blocks) |
Yes I am thinking about implementing this in LazyLoad. |
The only thing I'm still not understanding is: I never used the |
Anyway since I see the |
When I googled a bit to see if I could use the |
So for now I will only work on lazy loading the |
Yes, agree. Thanks for looking into it and all the clear information, @verlok! |
Feature added! See documentation and version 17.6.0. |
@matheusdigital did you have the chance to try it? |
@zvaehn would you be able to try this to lazyload your external SVGs with an |
@matheusdigital did you have any chance to try it out? |
@zvaehn , @matheusdigital |
Hey @zvaehn, @matheusdigital I didn't get any feedback 😞, but I'm closing this issue assuming it works. Feel free to reopen in case you need anything. If you’re happy with my support, the documentation and the effort I’ve been putting on this project in the latest years, I hope you might want to buy me a coffee to show your appreciation. Or sponsor me, if you're a fan. Open-source software is great for everyone, but it takes passion and time (and coffee!) to grow and evolve. Thank you for thinking about it. |
How about supporting the object-tag?
I am currently using this library for images and i would love to use it for svgs inside objects as well.
The text was updated successfully, but these errors were encountered: