So I am developing a reader for my comic and since the images take some time to download I wanted to preload them. Doing so meant having to create a Progress to display the progress of pages being downloaded before the reader can start reading it. I have it set up as you can see on this link here
I was wondering if there was a simple light weight code I can use to improve on. I was considering using Pace.JS but if there is a more light weight simple alternative then I'd prefer that cause I also want to learn how the ProgressBar works and perhaps improve it and learn more :D
If you check the link provided above it shows the page with the code I will put below implemented. After the pages load I will put jquery to hide the loading div. If possible can there be a way to also change the text alongside the download bar?
Sorry for so many questions, still learning >~<
HTML
<div id="loading">
<img id="loading_logo" class="animated infinite bounce" src="source_images/new_logo_compressed.png" />
<div id="progressbar">
<div></div>
</div>
<div class="text">Loading... 30%</div>
</div>
<a href="#" id="left" class="button hvr-icon-back"><div id="button_text">Next Page</div></a>
<a href="#" id="right" class="button hvr-icon-forward"><div id="button_text">Last Page</div></a>
<div >
<img id="manga" src="source_images/00.jpg" />
</div>
CSS
#loading {
background-color: black;
opacity: 0.75;
position: fixed;
z-index:1;
height:100%;
width:100%;
}
#loading_logo {
display: block;
margin-left: auto;
margin-right: auto;
padding-top: 30vh;
padding-bottom: 5vh;
width: 20vw;
}
#progressbar {
border: 3px solid #fff;
border-radius: 20px;
padding: 2px;
margin-left: 20vw;
margin-right: 20vw;
}
#progressbar > div {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background-color: #fff;
width: 30%;
height: 18px;
border: 1px solid rgba(0, 0, 0, 0);
border-radius: 20px;
}
.text {
color: #fff;
margin-top: 15px;
font-size: 21px;
font-weight: bold;
text-align: center;
}
Jquery (that makes reader work)
var count = 0;
var images = ["source_images/00.jpg", "source_images/01.jpg", "source_images/02.jpg", "source_images/03.jpg", "source_images/04.jpg", "source_images/05.jpg", "source_images/06.jpg"];
// Preloading Images
$.preloadImages = function() {
for (var i = 0; i < arguments.length; i++) {
$("<img />").attr("src", arguments[i]);
}
}
$.preloadImages("source_images/00.jpg", "source_images/01.jpg", "source_images/02.jpg", "source_images/03.jpg", "source_images/04.jpg", "source_images/05.jpg", "source_images/06.jpg");
$(function manga () {
$("#left").click(function () {
++count;
var img = images[count % images.length];
//alert(img);
$("#manga").attr("src", img);
//alert("clicked");
//manga();
});
$("#right").click(function () {
if(count == 0)
{
count = images.length-1;
}
else {
--count;
}
var img = images[count % images.length];
//alert(img);
$("#manga").attr("src", img);
//alert("clicked");
//manga();
});
//manga();
});