-
-
Save kavun/3fa3b60ed901e6a72c9b to your computer and use it in GitHub Desktop.
progress bar https://rawgit.com/kavun/3fa3b60ed901e6a72c9b/raw/b8f7c4fe1c9f2a7717cc86e23b7b67794adf1b05/index.html
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| body { | |
| font-family: Segoe UI; | |
| font-size: 11px; | |
| } | |
| .progress { | |
| background-color: #BDE; | |
| border: 1px solid #CCC; | |
| box-sizing: border-box; | |
| transition: width 0.5s ease; | |
| -webkit-transition: all 0.5s ease; | |
| } | |
| .progress-container { | |
| background-color: #EEE; | |
| height: 20px; | |
| text-align: center; | |
| line-height: 18px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="progress-container"></div> | |
| <script id="jsbin-javascript"> | |
| function progress(options) { | |
| var el = document.querySelector(options.selector); | |
| var prog = el.firstChild; | |
| if (!el.firstChild || el.firstChild.className !== options.progressClassName) { | |
| while (el.firstChild) { | |
| el.removeChild(el.firstChild); | |
| } | |
| prog = document.createElement('div'); | |
| el.appendChild(prog); | |
| } | |
| prog.style.height = '100%'; | |
| prog.style.width = options.percent + '%'; | |
| prog.className = options.progressClassName; | |
| if (options.showPercent) { | |
| prog.innerHTML = options.percent + '%'; | |
| } | |
| } | |
| var i = 0; | |
| function update() { | |
| progress({ | |
| selector: '.progress-container', | |
| percent: i++, | |
| progressClassName: 'progress', | |
| showPercent: true | |
| }); | |
| i += 5 | |
| if (i <= 100) { | |
| setTimeout(update, 1000) | |
| } else { | |
| i = 0; | |
| setTimeout(update, 1000) | |
| } | |
| } | |
| update() | |
| </script> | |
| <script id="jsbin-source-css" type="text/css">body { | |
| font-family: Segoe UI; | |
| font-size: 11px; | |
| } | |
| .progress { | |
| background-color: #BDE; | |
| border: 1px solid #CCC; | |
| box-sizing: border-box; | |
| transition: width 0.5s ease; | |
| -webkit-transition: all 0.5s ease; | |
| } | |
| .progress-container { | |
| background-color: #EEE; | |
| height: 20px; | |
| text-align: center; | |
| line-height: 18px; | |
| }</script> | |
| <script id="jsbin-source-javascript" type="text/javascript">function progress(options) { | |
| var el = document.querySelector(options.selector); | |
| var prog = el.firstChild; | |
| if (!el.firstChild || el.firstChild.className !== options.progressClassName) { | |
| while (el.firstChild) { | |
| el.removeChild(el.firstChild); | |
| } | |
| prog = document.createElement('div'); | |
| el.appendChild(prog); | |
| } | |
| prog.style.height = '100%'; | |
| prog.style.width = options.percent + '%'; | |
| prog.className = options.progressClassName; | |
| if (options.showPercent) { | |
| prog.innerHTML = options.percent + '%'; | |
| } | |
| } | |
| var i = 0; | |
| function update() { | |
| progress({ | |
| selector: '.progress-container', | |
| percent: i++, | |
| progressClassName: 'progress', | |
| showPercent: true | |
| }); | |
| i += 5 | |
| if (i <= 100) { | |
| setTimeout(update, 1000) | |
| } else { | |
| i = 0; | |
| setTimeout(update, 1000) | |
| } | |
| } | |
| update()</script></body> | |
| </html> |
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
| body { | |
| font-family: Segoe UI; | |
| font-size: 11px; | |
| } | |
| .progress { | |
| background-color: #BDE; | |
| border: 1px solid #CCC; | |
| box-sizing: border-box; | |
| transition: width 0.5s ease; | |
| -webkit-transition: all 0.5s ease; | |
| } | |
| .progress-container { | |
| background-color: #EEE; | |
| height: 20px; | |
| text-align: center; | |
| line-height: 18px; | |
| } |
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
| function progress(options) { | |
| var el = document.querySelector(options.selector); | |
| var prog = el.firstChild; | |
| if (!el.firstChild || el.firstChild.className !== options.progressClassName) { | |
| while (el.firstChild) { | |
| el.removeChild(el.firstChild); | |
| } | |
| prog = document.createElement('div'); | |
| el.appendChild(prog); | |
| } | |
| prog.style.height = '100%'; | |
| prog.style.width = options.percent + '%'; | |
| prog.className = options.progressClassName; | |
| if (options.showPercent) { | |
| prog.innerHTML = options.percent + '%'; | |
| } | |
| } | |
| var i = 0; | |
| function update() { | |
| progress({ | |
| selector: '.progress-container', | |
| percent: i++, | |
| progressClassName: 'progress', | |
| showPercent: true | |
| }); | |
| i += 5 | |
| if (i <= 100) { | |
| setTimeout(update, 1000) | |
| } else { | |
| i = 0; | |
| setTimeout(update, 1000) | |
| } | |
| } | |
| update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment