-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Normal
-
Affects Version/s: Freshly, 8.6.0, 8.5.2.1
-
Component/s: Components
-
Security Level: Jimmy
-
None
-
ZK 8.6.1 S1
-
None
Steps to Reproduce
run the attachment progressmeter-animation-not-catching-up.zul
click one button at a time (reload the browser between clicks)
Current Result
a high update rate of the progressbar value leads to animations not catching up with the actual value
Expected Result
stay closer to the actual value
Root Cause
1) the _fixImgWidth function of the progressmeter widget call jq.animate with the default option "queue:true" which makes each animation wait for the previous to finish, causing an increasing delay with higher update rates
-> set queue to false
2) the default easing starts at a slow speed -> restarting the animation at a high rate will remain in the slow bit of the animation most of the time
*-> consider: easing:'linear' to be closer to the current value
*
3) the animation speed is 'slow' so each animation takes at 600ms
-> consider default or fast update speed to be closer to the actual value
simplify the code by using percentage width, there's no need to convert from % to pixels
*-> just use % directly * (positive side effect, resizing is no longer necessary)
Workaround
override the _fixImgWidth function
zk.afterLoad('zul.wgt', function() { var xProgressmeter = {}; zk.override(zul.wgt.Progressmeter.prototype, xProgressmeter, { _fixImgWidth : function() { var n = this.$n(), img = this.$n('img'); if (img) { if (zk(n).isRealVisible()) { var $img = jq(img); $img.animate({ width: this._value + '%' /*use percent-value directly*/ }, { duration: $img.zk.getAnimationSpeed('slow'), /*slow = questionable? consider using default*/ queue: false, /*disable queueing*/ easing: "linear" }); } } } });//zk.override });//zk.afterLoad