I saw somebody used an algorithm to simulate the easeOutExpo effect with just the linear
parameter. The disadvantage of this code below is it needs a calculation:
step_value += (target_value - step_value)/25
. It looks very weird in the code.
How do I assign an easing function directly to jQuery in this case? Is it possible to just apply an easing function in this case without bringing jQuery UI or any other heavy framework in the code?
var step_value = 0;
var target_value = 90;
$({
someValue: 0
}).animate({
someValue: target_value
}, {
duration: 6800,
easing: 'linear',
step: function() {
step_value += (target_value - step_value)/25;
$('#text1').val(step_value);
},
complete: function(){
$('#text1').val(target_value).css('color', 'red');
}
});
/* This is my goal:
$({
someValue: 0
}).animate({
someValue: target_value
}, {
duration: 6800,
easing: 'easeOutExpo',
step: function() {
$('#text1').val(this.someValue);
},
complete: function(){
$('#text1').val(this.someValue).css('color', 'red');
}
});
*/
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="text1" />