OpenLayers OpenLayers

Ticket #1392: 1392-r6382-B1.diff

File 1392-r6382-B1.diff, 2.5 kB (added by pgiraud, 9 months ago)
  • tests/test_Tween.html

    old new  
    4646    } 
    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 
    5763    </script>  
  • lib/OpenLayers/Map.js

    old new  
    318318     *           Default is to fall through. 
    319319     */ 
    320320    fallThrough: true, 
     321     
     322    /** 
     323     * Property: panTween 
     324     * {OpenLayers.Tween} Animated panning tween object, see panTo() 
     325     */ 
     326    panTween: null, 
    321327 
    322328    /** 
    323329     * Constructor: OpenLayers.Map 
  • lib/OpenLayers/Tween.js

    old new  
    5858     */ 
    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 
    6369     * Creates a Tween. 
     
    8086     * options - {Object} hash of options (for example callbacks (start, eachStep, done)) 
    8187     */ 
    8288    start: function(begin, finish, duration, options) { 
     89        this.playing = true; 
    8390        this.begin = begin; 
    8491        this.finish = finish; 
    8592        this.duration = duration; 
     
    98105     
    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); 
    106118        } 
    107119        window.clearInterval(this.interval); 
    108120        this.interval = null; 
     121        this.playing = false; 
    109122    }, 
    110123     
    111124    /**