Skip to content

Commit

Permalink
Directly use DOM queue rencently introduced by #10530
Browse files Browse the repository at this point in the history
  • Loading branch information
karimnaaji committed May 6, 2021
1 parent a0d6705 commit 158dece
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/ui/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default class Marker extends Evented {
return this;
}

_evaluateOpacity(requestAnimationFrame: boolean = false) {
_evaluateOpacity() {
const position = this._pos ? this._pos.sub(this._transformedOffset()) : null;

if (!this._withinScreenBounds(position)) {
Expand All @@ -472,16 +472,8 @@ export default class Marker extends Evented {

const fogOpacity = this._map.queryFogOpacity(mapLocation);
const opacity = (1.0 - fogOpacity) * (terrainOccluded ? TERRAIN_OCCLUDED_OPACITY : 1.0);
const updateStyle = () => {
this._element.style.opacity = `${opacity}`;
if (this._popup) this._popup._setOpacity(`${opacity}`);
};

if (requestAnimationFrame) {
window.requestAnimationFrame(updateStyle);
} else {
updateStyle();
}
this._element.style.opacity = `${opacity}`;
if (this._popup) this._popup._setOpacity(`${opacity}`);

this._fadeTimer = null;
}
Expand Down Expand Up @@ -531,14 +523,16 @@ export default class Marker extends Evented {
}
this._map._requestDomTask(() => {
if (!this._map) return;
if (this._element && this._pos && this._anchor) {
DOM.setTransform(this._element, `${anchorTranslate[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${pitch} ${rotation}`);
}
});
if ((this._map.getTerrain() || this._map.getFog()) && !this._fadeTimer) {
this._fadeTimer = setTimeout(this._evaluateOpacity.bind(this, true), 60);
}
if ((this._map.getTerrain() || this._map.getFog()) && !this._fadeTimer) {
this._fadeTimer = setTimeout(this._evaluateOpacity.bind(this), 60);
}
});
}
/**
Expand Down

0 comments on commit 158dece

Please sign in to comment.