Created
August 6, 2015 14:07
-
-
Save ulizama/998c8f7722f0155955a2 to your computer and use it in GitHub Desktop.
Lazy loading images ScrollableView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gallery.addEventListener('scrollEnd',function(e){ | |
| //Make sure the current image is loaded | |
| var currentLoad = e.currentPage; | |
| galleryImages[currentLoad].backgroundImage = 'hotels/'+lightbox.uid+'/fullcard/'+currentLoad+'.jpg'; | |
| galleryTitles[currentLoad].text = ' ' + BSM.hotels[lightbox.uid].titles[currentLoad]; | |
| //Load Unload Images | |
| var nextLoad = e.currentPage + 1; | |
| var nextUnload = e.currentPage + 2; | |
| var prevUnload = e.currentPage - 2; | |
| var prevLoad = e.currentPage - 1; | |
| if( nextLoad < BSM.hotels[lightbox.uid].numberOfImages ){ | |
| galleryImages[nextLoad].backgroundImage = 'hotels/'+lightbox.uid+'/fullcard/'+nextLoad+'.jpg'; | |
| galleryTitles[nextLoad].text = ' ' + BSM.hotels[lightbox.uid].titles[nextLoad]; | |
| } | |
| if( nextUnload < BSM.hotels[lightbox.uid].numberOfImages ){ | |
| galleryImages[nextUnload].backgroundImage = 'transparent'; | |
| galleryTitles[nextUnload].text = ''; | |
| } | |
| if( prevLoad >= 0 ){ | |
| galleryImages[prevLoad].backgroundImage = 'hotels/'+lightbox.uid+'/fullcard/'+prevLoad+'.jpg'; | |
| galleryTitles[prevLoad].text = ' ' + BSM.hotels[lightbox.uid].titles[prevLoad]; | |
| } | |
| if( prevUnload >= 0 ){ | |
| galleryImages[prevUnload].backgroundImage = 'transparent'; | |
| galleryTitles[prevUnload].text = ''; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment