Changeset 11425

Show
Ignore:
Timestamp:
11/06/07 17:24:39 (13 months ago)
Author:
doughays
Message:

Fixes #2288. Added slideDuration attribute and added animation call for sliding.

Location:
dijit/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/Slider.js

    r11098 r11425  
    66dojo.require("dijit.form.Button"); 
    77dojo.require("dojo.number"); 
     8dojo.require("dojo._base.fx"); 
    89 
    910dojo.declare( 
     
    4041        //      If clicking the progress bar changes the value or not 
    4142        clickSelect: true, 
     43 
     44        // slideDuration: Number 
     45        //      The time in ms to take to animate the slider handle from 0% to 100% 
     46        slideDuration: 1000, 
    4247 
    4348        widgetsInTemplate: true, 
     
    120125                this.inherited('setValue', arguments); 
    121126                var percent = (value - this.minimum) / (this.maximum - this.minimum); 
    122                 this.progressBar.style[this._progressPixelSize] = (percent*100) + "%"; 
    123                 this.remainingBar.style[this._progressPixelSize] = ((1-percent)*100) + "%"; 
     127                if(priorityChange && this.slideDuration > 0 && this.progressBar.style[this._progressPixelSize]){ 
     128                        // animate the slider 
     129                        var _this = this; 
     130                        var props = {}; 
     131                        var start = parseFloat(this.progressBar.style[this._progressPixelSize]); 
     132                        var duration = this.slideDuration * (percent-start/100); 
     133                        if(duration < 0){ duration = 0 - duration; } 
     134                        props[this._progressPixelSize] = { start: start, end: percent*100, units:"%" }; 
     135                        dojo.animateProperty({ node: this.progressBar, duration: duration,  
     136                                onAnimate: function(v){_this.remainingBar.style[_this._progressPixelSize] = (100-parseFloat(v[_this._progressPixelSize])) + "%";}, 
     137                                properties: props 
     138                        }).play(); 
     139                } 
     140                else{ 
     141                        this.progressBar.style[this._progressPixelSize] = (percent*100) + "%"; 
     142                        this.remainingBar.style[this._progressPixelSize] = ((1-percent)*100) + "%"; 
     143                } 
    124144        }, 
    125145 
  • dijit/trunk/tests/form/test_Slider.html

    r10960 r11425  
    7979                </div> 
    8080                Slider2 Value:<input readonly id="slider2input" size="3" value="10"> 
    81                 <h1>Fancy HTML labels:</h1> 
     81                <h1>Fancy HTML labels (no slide animation):</h1> 
    8282                <div dojoType="dijit.form.HorizontalSlider" name="horizontal2" 
    8383                        minimum="1" 
     
    8787                        showButtons="false" 
    8888                        intermediateChanges="true" 
     89                        slideDuration="0" 
    8990                        style="width:300px; height: 40px;" 
    9091                        id="slider3">