Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i set divs to "visibility:hidden" if they are outside of viewport

I am developing mobile web app. However, safari in iOS 5.1 or below has limited memory. I need to minimize the memory usage when i use css3 transition. I found that if I use css style "display:none / visibility: hidden", The app will not crash by memory problem. So I want to make thing "hidden" when they are truly hidden. My English is bad. the picture can show what I want to:

uploaded image**:**

picture outlay

Another example which is a website used the css "visibility: hidden" property to hide every session when it is not on screen:

example website: Dentsu Network

like image 723
Chris So Avatar asked Sep 23 '12 15:09

Chris So


1 Answers

There's a plugin for jQuery offering viewport selectors.

You can set everything to visibility:hidden; and then show only the items in the viewport. Once the user scrolls you can re-grab the viewport elements and show them too.

 $(":in-viewport").css("visibility", "visible")
like image 132
Jamie Dixon Avatar answered Sep 30 '22 17:09

Jamie Dixon