Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4079

progressmeter animation not catching up with actual value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.6.1
    • Freshly, 8.6.0, 8.5.2.1
    • Components
    • Security Level: Jimmy
    • None
    • ZK 8.6.1 S1

      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
      

            Leon03 Leon03
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours Original Estimate - 4 hours
                4h
                Remaining:
                Time Spent - 3 days Remaining Estimate - 4 hours
                4h
                Logged:
                Time Spent - 3 days Remaining Estimate - 4 hours
                3d