views:

83

answers:

3

Hey,

Is there a way that I can only render the elements on the screen and leave those others to be rendered when they come into view?

Basically like 3d culling, but on a website ^.^

[edit] I take it that this isn't possible then? [/edit]
[edit2] I tried LazyLoad (jQuery plugin) but that initialised on windows scroll [/edit2]
[edit3] Sorry to keep bumping this, but I am tearing my hair out [/edit3]

+3  A: 

The Lazy Loader plugin will do the trick for images (demo here).

Lazy loader is a jQuery plugin written in JavaScript. It delays loading of images in (long) web pages. Images outside of viewport (visible part of web page) wont be loaded before user scrolls to them.

This plugin is based on YUI ImageLoader, so if you're not locked in to jQuery you might find using the original framework even better, depending on your specific use case.

ConroyP
Last I recall that plugin doesn't work properly in IE6 though.
meder
Good, IE6.. pfft! (and I don't want to hear how 30% of the web still uses IE6 either... I hate it, people who design sites hate it... let's leave it at that!)
Neurofluxation
IMHO, it's time to stop caring about IE6 users. And Neuroflux, I don't think it's anywhere near 30% anymore... I think it's < 10%
Daniel Schaffer
\o/ <(even better!)
Neurofluxation
Ok, so I tried this.. This fires up on windows Scroll... It needs to be when it comes into view as I have no scrollbars ...
Neurofluxation
+3  A: 

have you tried lazyload ? http://www.appelsiini.net/projects/lazyload

bharling
Yeah, this initialises on window scroll... I need it to initialise as it comes into view
Neurofluxation
+1  A: 

I'd suggest you use something like this: http://www.appelsiini.net/projects/lazyload - he has a demo page with the fade-in effect like mashable.com if that's what you're looking for.

You could always open it up and take only what you need from it, but it depends on your site/load requirements.

cdutson
hah. beaten to the punch by ConroyP and bharling
cdutson
@cdutson - Not quite, that wasn't what I was looking for. I need the Culling code to work as things come into view, not on windows scroll.
Neurofluxation
What would be the difference? items come into view when the page is scrolled... how else would you want them to load when they come into view? That is to say, are using something like a coverflow effect? where things slide in from off the page, but without a scrollbar?
cdutson
exactly...my page has no scrollbars... it doesnt really matter how i implemented it, i just cant have an "on scroll" event :(
Neurofluxation
how are you moving the items onto the screen? maybe during that animate you could check the scrolled items offset vs the page size and then fire off the load when it happens?http://www.reynoldsftw.com/2009/04/custom-events-in-jquery-open-doors-to-complex-behaviors/ might be able to help you... you can set conditions for when an event happens, so maybe you can do that?
cdutson
Excellent idea, that worked a treat. Cheers (can't believe I didn't think of that though...)
Neurofluxation