My current challenge involves implementing a progress bar, similar to the pace.js progress bar. The issue arises when the browser is refreshed, as the pace.js progress bar loads on top of the body instead of within a specified div. It is important that the loader only appears upon clicking a button and is positioned at the top of a specific div.
I am striving to recreate the loading experience seen when logging into Google, where a progress bar animates at the top of the page. To achieve this functionality, I initially tried using pace.js. However, I am open to exploring other libraries that offer more customization options to solve this problem effectively.
function createDiv(event) {
event.target.disabled = true;
var html = '';
html += '<div id="paceProgressBarBox" style="background:#ccc;width:200px;height:200px;"></div>';
$('#myDiv').append(html)
// add pace progress bar at the top of id="paceProgressBarBox" and stop pace progress bar loading on browser referesh // instead show pace progress bar on click of button
var pace;
pace.options.target = '#paceProgressBarBox';
pace.start();
}
.pace {
-webkit-pointer-events: none;
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.pace-inactive {}
.pace .pace-progress {
background: #2299dd;
position: relative;
z-index: 2000;
right: 100%;
width: 100%;
height: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.js">
</script>
<br/>
<button onclick="createDiv(event)">Change Content</button>
<div id="myDiv" style="width:200px;height:200px;"></div>