Coder Social home page Coder Social logo

Comments (21)

TheEskhaton avatar TheEskhaton commented on July 18, 2024

wouldn't that be easily achieved by calling .trigger('unveil') on lets say the images that the sorting/filtering script has shown?

from unveil.

ErtugKaya avatar ErtugKaya commented on July 18, 2024

Thank you, but does not that includes writing a script for detecting images that are on view-port? What I meant is unveil should be aware of which images to load, by triggering or automatically.

Please take a look at this similar project and similar request: tuupola/lazyload#58

from unveil.

TheEskhaton avatar TheEskhaton commented on July 18, 2024

Hmm yeah i guess it isn't that simple as a thought it was.

from unveil.

MarkReeder avatar MarkReeder commented on July 18, 2024

You can trigger unveiling of visibile images with: $(window).trigger('scroll')

from unveil.

Yahasana avatar Yahasana commented on July 18, 2024

$("img:visible").trigger( "unveil" )

from unveil.

joeldbirch avatar joeldbirch commented on July 18, 2024

I'm wrestling with this also. The images in the viewport do not load on iOS Safari until a scroll occurs. The proposed workarounds don't seem to work. @MarkReeder's idea doesn't cause the images to be loaded on iOS Safari and @Yahasana's idea loads all of the images as if they are all visible.

The logic for detecting whether the image is within the viewport is within the private function unveil so I guess that just needs to be exposed somehow.

from unveil.

joeldbirch avatar joeldbirch commented on July 18, 2024

I have this horrible workaround working in iOS Safari. It's horrible because it uses a timer to fire code that is a duplicate of what already exists within the plugin. Also, the length of the timer is unreliable—a timer of 10ms doesn't work, for example, and sometimes 100 doesn't work. I'm not sure what that is based on, but possibly image loading time?

// set a threshold
var th = 200;

// apply unveil behaviour to images
var images = $('img');
images.unveil( th );

// force iOS Safari to load images that are visible on page load
setTimeout( function() {
    inview = images.filter(function() {
        var $e = $(this),
            wt = $w.scrollTop(),
            wb = wt + $w.height(),
            et = $e.offset().top,
            eb = et + $e.height();

        return eb >= wt - th && et <= wb + th;
    });

    inview.trigger("unveil");
},100);

from unveil.

ErtugKaya avatar ErtugKaya commented on July 18, 2024

Thank you guys for all your ideas. Joeldbirch's solution is a good pointer, but as he mentions, we need to get rid of the timer.

from unveil.

luis-almeida avatar luis-almeida commented on July 18, 2024

@ErtugKaya, @joeldbirch, Sorry "I'm late to the party", but here's my feedback:

You could extend jQuery with an :inview selector and then do the following after a filter as been applied:

$("img:inview").trigger("unveil")

You can grab the code for this selector from this gist.

Doing this through unveil is fairly simple as well. You can grab the "forked" code from this fiddle.
Then you could simply do the following whenever you want to show all the visible images in the viewport:

$(window).trigger("unveil")

from unveil.

joeldbirch avatar joeldbirch commented on July 18, 2024

Thanks @luis-almeida. This certainly seems like it will help, but I wonder if you have any input on the iOS issue? The code you've added here probably still doesn't address that, or maybe I'm missing something. And I guess this should be moved to its own, separate issue.

from unveil.

luis-almeida avatar luis-almeida commented on July 18, 2024

@joeldbirch are you initializing unveil after the document is ready?
I'm sorry but I'm not really understanding what the problem with iOS is.
Could you please open a separate issue with the description of the problem and a way to reproduce?

from unveil.

joeldbirch avatar joeldbirch commented on July 18, 2024

Yes, initialising on document ready (or even window load) does not unveil images in iOS Safari until the user manually triggers a scroll event. I'll open a separate issue and provide a test case as soon as I can. Thanks again.

from unveil.

luis-almeida avatar luis-almeida commented on July 18, 2024

Hmmmm... Then it's a bug and I have to take a better look at it.
Thanks!

from unveil.

joeldbirch avatar joeldbirch commented on July 18, 2024

Actually, it looks like #20 is the same bug and has a pull request with a possible fix!

from unveil.

joeldbirch avatar joeldbirch commented on July 18, 2024

Maybe I got too excited there. Not sure the patch submitted is a proper fix.

from unveil.

luis-almeida avatar luis-almeida commented on July 18, 2024

I don't think that running unveil on load might fix it.
I have to take a better look at the problem.

from unveil.

CourtFantinato avatar CourtFantinato commented on July 18, 2024

Hello,

I am having the same issue as the original poster. I am wondering since this thread is a few months old if there is a updated way of addressing content that gets filtered, or if using $("img:inview").trigger("unveil") is the only way at this point? I am currently using it, but I am finding it still doesn't work properly. Some images are in view but aren't shown until I scroll.

Thanks!

from unveil.

hughred22 avatar hughred22 commented on July 18, 2024

I am having the same issue. I use Isotope to filter images. When window finish loading, the images will not show until scroll. When filter apply, it will not show until I scroll...

from unveil.

zachcarroll avatar zachcarroll commented on July 18, 2024

any updates on this? I ran into this exact same problem... On page load, images don't load, I find I need to scroll to trigger unveil. Any cross-browser way to trigger unveil on only images in viewport on page load?

from unveil.

Tyler-Hall avatar Tyler-Hall commented on July 18, 2024

@zachcarroll It seems as though you can add a load.unveil to the .on() function to fix the problem where your images don't load until you scroll like this

$w.on("scroll.unveil resize.unveil lookup.unveil load.unveil", unveil);

instead of the original

$w.on("scroll.unveil resize.unveil lookup.unveil", unveil);

let me know if this was a suitable solution

from unveil.

zachcarroll avatar zachcarroll commented on July 18, 2024

Tyler,

Thank you very much. My attention has shifted elsewhere for the time being, but when I get back to this project I will definitely reach back out to you to let you know how it went. Thanks for your time on this!

Best,
Zach

On Jul 29, 2014, at 8:54 AM, Tyler Hall [email protected] wrote:

@zachcarroll It seems as though you can add a load.unveil to the .on() function to fix the problem where your images don't load until you scroll like this

$w.on("scroll.unveil resize.unveil lookup.unveil load.unveil", unveil);
instead of the original

$w.on("scroll.unveil resize.unveil lookup.unveil", unveil);
let me know if this was a suitable solution


Reply to this email directly or view it on GitHub.

from unveil.

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.