OpenLayers OpenLayers

Changeset 6387

Show
Ignore:
Timestamp:
02/27/08 08:57:13 (11 months ago)
Author:
pgiraud
Message:

add a new 'playing' property to the Tween class so that a call to stop doesn't do anything if animation is already finished, r=ahocevar,crschmidt (Closes #1392)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Map.js

    r6329 r6387  
    319319     */ 
    320320    fallThrough: true, 
     321     
     322    /** 
     323     * Property: panTween 
     324     * {OpenLayers.Tween} Animated panning tween object, see panTo() 
     325     */ 
     326    panTween: null, 
    321327 
    322328    /** 
  • trunk/openlayers/lib/OpenLayers/Tween.js

    r6131 r6387  
    5959    interval: null, 
    6060     
     61    /** 
     62     * Property: playing 
     63     * {Boolean} Tells if the easing is currently playing 
     64     */ 
     65    playing: false, 
     66     
    6167    /**  
    6268     * Constructor: OpenLayers.Tween 
     
    8187     */ 
    8288    start: function(begin, finish, duration, options) { 
     89        this.playing = true; 
    8390        this.begin = begin; 
    8491        this.finish = finish; 
     
    99106    /** 
    100107     * APIMethod: stop 
    101      * Stops the Tween, and calls the finish callback 
     108     * Stops the Tween, and calls the done callback 
     109     *     Doesn't do anything if animation is already finished 
    102110     */ 
    103111    stop: function() { 
     112        if (!this.playing) { 
     113            return 
     114        } 
     115         
    104116        if (this.callbacks && this.callbacks.done) { 
    105117            this.callbacks.done.call(this, this.finish); 
     
    107119        window.clearInterval(this.interval); 
    108120        this.interval = null; 
     121        this.playing = false; 
    109122    }, 
    110123     
  • trunk/openlayers/tests/test_Tween.html

    r6131 r6387  
    4747 
    4848    function test_Tween_stop(t) { 
    49         t.plan(1); 
     49        t.plan(2); 
    5050         
    5151        var tween = new OpenLayers.Tween(); 
    5252        tween.interval = window.setInterval(function() {}, 10); 
     53        tween.playing = true; 
    5354        tween.stop(); 
    5455        t.eq(tween.interval, null, "tween correctly stopped"); 
     56         
     57        tween.interval = window.setInterval(function() {}, 10); 
     58        tween.playing = false; 
     59        tween.stop(); 
     60        t.ok(tween.interval != null, "stop method doesn't do anything if tween isn't running"); 
    5561    } 
    5662