Ticket #107: 107.2.patch

File 107.2.patch, 3.3 kB (added by tschaub, 1 year ago)

don't tween and count moves per action

  • tests/lib/GeoExt/widgets/Popup.html

    old new  
    1111 
    1212        function setupContext() {         
    1313 
    14             var map = new OpenLayers.Map(); 
     14            var map = new OpenLayers.Map({panMethod: null}); // avoid tween panning for tests 
    1515            var layer = new OpenLayers.Layer("test", {isBaseLayer: true}); 
    1616            map.addLayer(layer); 
    1717 
     
    7070            pop.show(); 
    7171 
    7272            t.ok(Ext.getBody().child("div." + pop.popupCls),"viewport contains popup"); 
    73              
     73 
    7474            tearDown(context); 
    7575        } 
    7676 
    7777        function test_anchorPopup(t) { 
    78             t.plan(4); 
     78            t.plan(5); 
    7979 
    8080            var context = setupContext(); 
    8181 
    8282            var pop = popup(context.feature); 
    8383 
     84            // show the popup and move the map to ensure popup is actually visible 
    8485            pop.show(); 
    85  
     86            context.map.setCenter(new OpenLayers.LonLat(5, 45)); 
     87             
     88            var moves = 0; 
    8689            pop.on({ 
    87                 'move' : function(c,x,y)
    88                     t.ok(true,"Move event fired on " + action); //should happen twice, on call to position() 
     90                move: function()
     91                    ++moves; 
    8992                }, 
    9093                scope : this 
    9194            }); 
    9295 
    9396            t.ok(pop.getAnchorElement(), "Popup has anchor element"); 
    9497 
    95             var action = "map move"; 
    96             context.map.events.triggerEvent("move"); 
    97              
    98             action = "popup collapse"; 
     98            // move the map and confirm that popup moves 
     99            context.map.setCenter(new OpenLayers.LonLat(6, 45)); 
     100            t.eq(moves, 1, "anchored popup moves once on map.setCenter"); 
     101            moves = 0; 
     102 
     103            // anchored popup needs to reposition on collapse, resize and 
     104            // expand to keep the anchor point on the feature 
     105 
     106            // collapse popup and and confirm that it moves 
    99107            pop.collapse(); 
     108            t.eq(moves, 1, "anchored popup moves once on collapse"); 
     109            moves = 0; 
    100110 
    101             action = "popup expand" 
     111            // expand popup and confirm that it moves 
    102112            pop.expand(); 
     113            t.eq(moves, 1, "anchored popup moves once on expand"); 
     114            moves = 0; 
    103115             
     116            // resize popup and confirm that it moves 
     117            pop.setSize(100, 100); 
     118            t.eq(moves, 1, "anchored popup moves once on resize"); 
     119            moves = 0; 
     120 
    104121            tearDown(context); 
    105122        } 
    106123 
     
    113130            var pop = popup(context.feature, context.mapPanel); 
    114131 
    115132            pop.show(); 
    116          
     133 
    117134            pop.collapse(); 
    118135 
    119136            var origPos = pop.getPosition(); 
  • lib/GeoExt/widgets/Popup.js

    old new  
    170170        GeoExt.Popup.superclass.show.apply(this, arguments); 
    171171        if(this.anchored) { 
    172172            this.position(); 
    173             if(this.panIn && !this._mapmove) { 
     173            if(this.panIn && !this._mapMove) { 
    174174                this.panIntoView(); 
    175175            } 
    176176        }