vvo / in-viewport

Get a callback when any element becomes visible in a viewport (body or custom viewport)
MIT License
276 stars 24 forks source link

Android 2.1 support #2

Closed flamez-b closed 10 years ago

flamez-b commented 10 years ago

I was looking for a plugin to add a class depending on visibility of divs so that to use it as lazyloader for css-backgrounds. I have tested different inview-plugins, so yours is the only one I found that behaves as expected on mobile devices. The results were perfect in latest browsers on Android 4+ and iOS 7. But I have also tried on my old Xperia with Android 2.1 – nothing appeared at all (expected image was not loaded). I tested with the in-viewport v0.4.1 and with this callback: var el = document.querySelector("footer"); inViewport(el, { offset: 333 }, visible); function visible() { el.classList.add("inview"); } html: footer role="contentinfo" …… /footer css: footer[role="contentinfo"] { background: url(../images/bg-diagonal.png) #7c7585; } footer[role="contentinfo"].inview { background: url(../images/bg-diagonal.png), url(../images/rope-2x.jpg) no-repeat; } Maybe there is something wrong with these codes or the Plugin itself is not supposed to support old Androids?

Also please tell how to specify a few tags in javascript to call the Plugin (like $("header, nav, footer") in jquery)?

Thank you in advance. P.S. Have just checked through Browserstack.com on old desktop browsers, works on: Firefox 3.6+, IE 10+, Safari 5+, Chrome 14+, Opera 11.5+ . Doesn’t work on IE 8-9.

vvo commented 10 years ago

Maybe there is something wrong with these codes or the Plugin itself is not supposed to support old Androids?

Maybe! I really don't know, I feel that trying to support Android 2.1 is like trying to support IE6, lot of work for very very few users: http://www.appbrain.com/stats/top-android-sdk-versions

I cannot help you debug this but you should be able to debug it yourself if you find a way to debug web pages in Android 2.1. I know how to do it on recent devices (remote debugging) but not on very old ones.

flamez-b commented 10 years ago

Yes, you are quite right. That old stuff is just a matter of habbit, I guess... What about multiple selecots? Or this question is better to be moved to another topic?

vvo commented 10 years ago

yes its another issue but there is no selector with in-viewport you only pass a dom element so it's up to you to do a multiple selector thing