Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a loading indicator/spinner

  • Loading branch information...
commit 0d216108d875845c0eaf4b3be2f3cd41ea733532 1 parent d59b53b
@blaine authored
View
17 book.css
@@ -239,3 +239,20 @@ div#selector .selection img {
height: 80px;
margin: 20px auto 0;
}
+
+div#spinner {
+ background-color: rgba(55, 46, 74, 0.8);
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ top: 100px;
+ left: 50%;
+ margin-left: -50px;
+ display: none;
+ border-radius: 20px;
+ -webkit-border-radius: 20px;
+}
+
+div#spinner img {
+ margin: 34px;
+}
View
3  index.html
@@ -60,6 +60,9 @@
</head>
<body>
+ <div id="spinner">
+ <img src="loader.gif" alt="Loading" />
+ </div>
<div id="selector">
<div style="text-align: center; font-family: Helvetica, sans; margin-top: 20px; background-color: rgba(255,255,255,0.3); line-height: 1.5em;">
<span style="color: #0000dd">r</span><span style="color: #4444ee">ePub</span><span style="color: #0000dd">lish</span> &#8212; Pure-JavaScript ePub Reader
View
23 js/pageHandler.js
@@ -81,21 +81,18 @@ var PageHandler = function (book, displayElements, pageNumbers, chapterName) {
currPage = lastPage;
};
- this.nextPage = function () {
- this.loadCallback();
- if (!this.isLastPage()) {
- currPage += displayElements.length;
- }
- };
+ var loadingIndicator;
+ var waiting = 0;
- this.prevPage = function () {
- this.loadCallback();
- currPage = Math.max(0, currPage - displayElements.length);
- }
+ var showLoadingIndicator = function (t) {
+ loadingIndicator = setTimeout( function () {
+ document.getElementById('spinner').style.display = 'block';
+ }, t);
+ };
- this.addPage = function (page) {
- pages.push(page);
- };
+ var hideLoadingIndicator = function () {
+ clearTimeout(loadingIndicator);
+ document.getElementById('spinner').style.display = 'none';
};
this.display = function () {
View
BIN  loader.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.