OpenLayers OpenLayers

Changeset 5569

Show
Ignore:
Timestamp:
12/24/07 11:51:23 (1 year ago)
Author:
tcoulter
Message:

Fixed two bugs:
1) Fixed a bug where the scrollbar width wasn't taken into account when sizing, thus creating need for a horizontal scrollbar when there wasn't any need, (See Vescpucci bug report http://trac.openplans.org/nymap/ticket/65), and
2) Fixed a scrollbar flicker when a popup loaded that was too large.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/GooglePopups/openlayers/lib/OpenLayers/Popup.js

    r5537 r5569  
    171171         
    172172        this.registerEvents(); 
     173         
     174        // Not sure if this should be here or elsewhere... 
     175         
     176        // Although in some windowing systems there is a chance that the scroll 
     177        // bar may change widths while our application is running, lets assume it 
     178        // won't only calculate it once. 
     179        if (!OpenLayers.Popup.SCROLL_BAR_WIDTH) { 
     180            // We have to set this at a time after the document has loaded... 
     181            OpenLayers.Popup.SCROLL_BAR_WIDTH = OpenLayers.Util.getScrollBarWidth(); 
     182        } 
    173183    }, 
    174184     
     
    351361         
    352362        // Calculate the difference between the container and the content 
    353         // and scale the content accordingly.  
    354         var widthDifference = size.w - (mapSize.w - OpenLayers.Popup.POPUP_MARGIN.left - OpenLayers.Popup.POPUP_MARGIN.right); 
    355         var heightDifference = size.h - (mapSize.h - OpenLayers.Popup.POPUP_MARGIN.top - OpenLayers.Popup.POPUP_MARGIN.bottom); 
     363        // and scale the content accordingly. 
     364        var heightDifference = size.h -  
     365            (mapSize.h -  
     366             OpenLayers.Popup.POPUP_MARGIN.top -  
     367             OpenLayers.Popup.POPUP_MARGIN.bottom); 
    356368         
    357369        if (heightDifference > 0) { 
     
    359371        } 
    360372         
     373        var widthDifference = size.w -  
     374            (mapSize.w -  
     375             OpenLayers.Popup.POPUP_MARGIN.left -  
     376             OpenLayers.Popup.POPUP_MARGIN.right + 
     377             OpenLayers.Popup.SCROLL_BAR_WIDTH); 
     378         
    361379        if (widthDifference > 0) { 
    362380            size.w -= widthDifference; 
     381        } else if (size.w + OpenLayers.Popup.SCROLL_BAR_WIDTH < mapSize.w){ 
     382            size.w += OpenLayers.Popup.SCROLL_BAR_WIDTH; 
    363383        } 
    364384         
  • sandbox/GooglePopups/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js

    r5511 r5569  
    6969        this.contentDiv.style.left = this.CONTENT_PADDING + "px"; 
    7070        this.contentDiv.style.top = this.CONTENT_PADDING + "px"; 
     71         
     72        // Make the contentDiv relative to prevent scrollbar flicker. 
     73        this.contentDiv.style.position = "relative"; 
    7174    }, 
    7275     
  • sandbox/GooglePopups/openlayers/lib/OpenLayers/Util.js

    r5537 r5569  
    13661366} 
    13671367 
    1368  
     1368// Pilferred from here: 
     1369// http://www.fleegix.org/articles/2006/05/30/getting-the-scrollbar-width-in-pixels 
     1370OpenLayers.Util.getScrollBarWidth = function() { 
     1371    var scr = null; 
     1372    var inn = null; 
     1373    var wNoScroll = 0; 
     1374    var wScroll = 0; 
     1375 
     1376    // Outer scrolling div 
     1377    scr = document.createElement('div'); 
     1378    scr.style.position = 'absolute'; 
     1379    scr.style.top = '-1000px'; 
     1380    scr.style.left = '-1000px'; 
     1381    scr.style.width = '100px'; 
     1382    scr.style.height = '50px'; 
     1383    // Start with no scrollbar 
     1384    scr.style.overflow = 'hidden'; 
     1385 
     1386    // Inner content div 
     1387    inn = document.createElement('div'); 
     1388    inn.style.width = '100%'; 
     1389    inn.style.height = '200px'; 
     1390 
     1391    // Put the inner div in the scrolling div 
     1392    scr.appendChild(inn); 
     1393    // Append the scrolling div to the doc 
     1394    document.body.appendChild(scr); 
     1395 
     1396    // Width of the inner div sans scrollbar 
     1397    wNoScroll = inn.offsetWidth; 
     1398    // Add the scrollbar 
     1399    scr.style.overflow = 'auto'; 
     1400    // Width of the inner div width scrollbar 
     1401    wScroll = inn.offsetWidth; 
     1402 
     1403    // Remove the scrolling div from the doc 
     1404    document.body.removeChild( 
     1405        document.body.lastChild); 
     1406 
     1407    // Pixel width of the scroller 
     1408    return (wNoScroll - wScroll); 
     1409