Hi, here's my three-line optimization with only one replacement in original code: --- new part--- var currentValue = $("#innerDiv").text(); var position = (currentValue == "") ? 1 : parseInt(currentValue.substr(0, currentValue.indexOf("%"))); percentageCompleted = (position > percentageCompleted) ? --percentageCompleted : percentageCompleted; --- new part--- After this, just change the "count" part of code, replace number "1" with "position" variable: - old: $({ count: 1}).animate....(rest of code) - new: $({ count: position }).animate.....(rest of code) Thank you mr Venkat for giving us the opportunity to learn all these topic in your tutorials, and helping us to improve ourselves!
@artemboss19999 жыл бұрын
percentages may be rounded as follows: $('#innerDiv').text(Math.round(this.count) + ' %'); and then you do not need to subtract one value
@GXEngineChannel8 жыл бұрын
индусский код, ничего тут не поделать))
@conaxliu96779 жыл бұрын
If there are multiple properties being animated (eg. width and height), it seems like 'now' only works with the last property in the JSON object. Is there anyway to get 'now' for all the properties?
@betaakurnia39985 жыл бұрын
who is optim a
@adnanjlassi53328 жыл бұрын
Thank you for your tutorial, it helped me a lot :)