- , animation transition . Bugzilla ( animation transition).
, width max-width . , , , .
width, width, max-width . width animation, max-width transition.
(function() {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
$("#btnResize").on("click", function() {
$(".bar").css({
"max-width": getRandomInt(1, 300) + "px"
});
});
})();
.container {
width: 100%;
position: relative;
margin: 1em;
}
.bar {
height: 3px;
background-color: blue;
position: absolute;
transition: margin-left 0.5s ease-in-out, max-width 0.5s ease-in-out;
animation: progress-bar 1s 0.2s ease both;
}
.actions {
padding-top: 30px;
}
@keyframes progress-bar {
0% {
width: 0
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="bar" style="width: 300px; max-width: 300px"></div>
<div class="actions">
<button id="btnResize">Resize</button>
</div>
</div>
max-width animation, width transition. , .
(function() {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
$("#btnResize").on("click", function() {
$(".bar").css({
"width": getRandomInt(1, 300) + "px"
});
});
})();
.container {
width: 100%;
position: relative;
margin: 1em;
}
.bar {
height: 3px;
background-color: blue;
position: absolute;
transition: margin-left 0.5s ease-in-out, width 0.5s ease-in-out;
animation: progress-bar 1s 0.2s ease both;
}
.actions {
padding-top: 30px;
}
@keyframes progress-bar {
0% {
max-width: 0
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="bar" style="width: 300px; max-width: 300px"></div>
<div class="actions">
<button id="btnResize">Resize</button>
</div>
</div>