Комментарии:
who is optim a
ОтветитьThank you for your tutorial, it helped me a lot :)
Ответить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!
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?
Ответитьpercentages may be rounded as follows:
$('#innerDiv').text(Math.round(this.count) + ' %');
and then you do not need to subtract one value
Thank you Sir.
Ответить