Further image loading smoothing
This commit is contained in:
		
							parent
							
								
									0355d1e0db
								
							
						
					
					
						commit
						ac2a51f066
					
				
					 3 changed files with 28 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -13,7 +13,7 @@
 | 
			
		|||
 | 
			
		||||
#reader-pages > img {
 | 
			
		||||
    display: inline-block;
 | 
			
		||||
    opacity:0;
 | 
			
		||||
    opacity: 0;
 | 
			
		||||
    transition: all 1s cubic-bezier(.9,.03,.69,.22); /* ease-in quartic */
 | 
			
		||||
    flex-shrink: 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -97,12 +97,27 @@ function totalPagesWidth() {
 | 
			
		|||
function initReader(){
 | 
			
		||||
    moveReaderDisplayToZoom(0)
 | 
			
		||||
    
 | 
			
		||||
    // Smoothly show pictures when they intersect with the viewport
 | 
			
		||||
    let visibilityObserver = new IntersectionObserver((entries, observer) => {
 | 
			
		||||
        entries.forEach((entry) => {
 | 
			
		||||
            if (entry.isIntersecting) {
 | 
			
		||||
                entry.target.style.opacity = 1
 | 
			
		||||
                entry.target.style.visibility = "visible"
 | 
			
		||||
            } else {
 | 
			
		||||
                entry.target.style.opacity = 0
 | 
			
		||||
                entry.target.style.visibility = "hidden"
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }, { root: READER_FRAME, rootMargin: "-10px" });
 | 
			
		||||
    
 | 
			
		||||
    for (var i = 0; i < READER_PAGES.children.length; i++) {
 | 
			
		||||
        let img = READER_PAGES.children[i];
 | 
			
		||||
        img.style.width = 100 / getPagesCount() + "%"
 | 
			
		||||
        visibilityObserver.observe(img)
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    READER_PAGES.style.display = "flex"
 | 
			
		||||
    
 | 
			
		||||
    setTimeout(() => {
 | 
			
		||||
        READER_PAGES.hidden = false
 | 
			
		||||
    }, "300")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,18 +12,18 @@
 | 
			
		|||
    
 | 
			
		||||
        <div id="reader-frame">
 | 
			
		||||
            <div id="reader-pages" data-pages-width="2481" data-pages-height="3503" hidden>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P01.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P02.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P03.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P04.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P05.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P06.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P07.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P08.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P09.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P10.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P11.jpg"/>
 | 
			
		||||
                <img loading="lazy" onload="event.target.style.opacity=1" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P12.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P01.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P02.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P03.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P04.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P05.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P06.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P07.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P08.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P09.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P10.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P11.jpg"/>
 | 
			
		||||
                <img loading="lazy" src="https://www.peppercarrot.com/0_sources/ep35_The-Reflection/hi-res/en_Pepper-and-Carrot_by-David-Revoy_E35P12.jpg"/>
 | 
			
		||||
            </div>
 | 
			
		||||
            
 | 
			
		||||
            <div id="focus-overlay">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue