I'm currently exploring the <progress>
element and attempting to incorporate a CSS transition to achieve a smooth progress bar effect as its value increases. Despite my efforts, I can't seem to trigger JS after the transitionend
event occurs.
Where could I be making a mistake?
$("button").on("click", function () {
$("progress").val(100);
});
$("progress[value]").on(
"transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",
function () {
$("progress").val(0);
alert("Completed");
}
);
body {
margin: 0;
padding: 0;
text-align: center;
}
button {
margin: 10px;
text-transform: uppercase;
font-size: 1em;
}
.loadPageProgress progress {
display: block;
width: 100%;
height: 5px;
border: none;
border-radius: 0;
background-color: green;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
.loadPageProgress progress[value] {
background-color: green;
transition: all 1000ms ease-in-out;
-webkit-transition: all 1000ms ease-in-out;
-moz-transition: all 1000ms ease-in-out;
-o-transition: all 1000ms ease-in-out;
}
.loadPageProgress progress[value]::-webkit-progress-bar {
width: 100%;
height: 5px;
border: none;
border-radius: 0;
background-color: grey;
}
.loadPageProgress progress[value]::-webkit-progress-value {
background-color: green;
transition: all 1000ms ease-in-out;
-webkit-transition: all 1000ms ease-in-out;
-moz-transition: all 1000ms ease-in-out;
-o-transition: all 1000ms ease-in-out;
}
.loadPageProgress progress[value]::-moz-progress-bar {
width: 100%;
height: 5px;
border: none;
border-radius: 0;
background-color: grey;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="loadPageProgress">
<progress value="0" max="100"></progress>
</div>
<button>start transition</button>