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

slider doesn't show custom slidertext initially

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.5.0
    • Freshly, 8.0.5, 8.5.0
    • Components
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      <slider vflex="1" maxpos="4" orient="vertical" slidingtext="Test {0}"/>
      

      start dragging the mouse

      Current Result

      initially the slidertip shows "0"
      when dragging further the slidingtext property is used correctly showing "Text 1..5"

      Expected Result

      show the correct text also initially

      Root Cause

      https://github.com/zkoss/zk/blob/v8.0.5/zul/src/archive/web/js/zul/inp/Slider.js#L320
      initially only the scrollpos is rendered without expanding the slidingtext

      Workaround

      override _startDrag any copied the related code from _dragging

      zk.afterLoad('zul.inp', function() {
      	var xSlider = {};
      	zk.override(zul.inp.Slider.prototype, xSlider, {
      		_startDrag : function(dragInfo) {
      			var result = xSlider._startDrag.apply(this, arguments); //call original method
      			var sliderWgt = dragInfo.control;
      			if (sliderWgt.slidetip) {
      				//set the given slidertext also initially ZK-xxxx
      				var isDecimal = sliderWgt.isDecimal(),
      					pos = sliderWgt._realpos();
      				var text = isDecimal ? pos.toFixed(_digitsAfterDecimal(_getStep(widget))) : pos;
      				sliderWgt.slidetip.innerHTML = sliderWgt._slidingtext.replace(/\{0\}/g, text);
      			}
      			return result;
      		}
      	});//zk.override
      });//zk.afterLoad
      
      

            bobpeng bobpeng
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h