no longer rely on the transitionend event, unwanted flashes are avoid using a timer

This commit is contained in:
Éric Lemoine
2012-01-02 22:53:53 +01:00
parent aeccee865c
commit eb924c8f77
3 changed files with 38 additions and 103 deletions

View File

@@ -359,27 +359,12 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
var img = this.imgDiv;
OpenLayers.Event.stopObservingElement(img);
var opacity = this.layer.opacity,
tileAnimation = this.layer.map.tileAnimation;
if (OpenLayers.Tile.Image.TRANSITION && tileAnimation && opacity) {
// if the displaying of the tile is animated we delay the
// loadend event until after the end of the transition, this
// to avoid flash effects because the backbuffer is removed
// before the tile is actually displayed
OpenLayers.Event.observe(img, OpenLayers.Tile.Image.TRANSITION_END,
OpenLayers.Function.bind(this.onTransitionEnd, this)
);
}
img.style.visibility = 'inherit';
img.style.opacity = opacity;
img.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
img.style.opacity = this.layer.opacity;
img.style.filter = 'alpha(opacity=' + (this.layer.opacity * 100) + ')';
if (!OpenLayers.Tile.Image.TRANSITION || !tileAnimation || !opacity) {
this.isLoading = false;
this.events.triggerEvent("loadend");
}
this.isLoading = false;
this.events.triggerEvent("loadend");
// IE<7 needs a reflow when the tiles are loaded because of the
// percentage based positioning. Otherwise nothing is shown
@@ -432,34 +417,3 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
CLASS_NAME: "OpenLayers.Tile.Image"
});
// Test for support of CSS transitions and store appropriate property names
(function() {
function testProp(props) {
var style = document.documentElement.style;
for (var i=0; i<props.length; i++) {
if(props[i] in style) {
return props[i];
}
}
return false;
}
var TRANSITION = testProp([
'transition', 'webkitTransition', 'MozTransition'
]);
var TRANSITION_END = TRANSITION === 'webkitTransition' ?
TRANSITION + 'End' : 'transitionend';
/**
* Constant: OpenLayers.Tile.Image.TRANSITION
*/
OpenLayers.Tile.Image.TRANSITION = TRANSITION;
/**
* Constant: OpenLayers.Tile.Image.TRANSITION_END
*/
OpenLayers.Tile.Image.TRANSITION_END = TRANSITION_END;
})();