mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-29 11:53:03 +00:00
Avoid multiple canvas updatePaths/redraws during viewreset (#5250)
* Avoid multiple canvas updatePaths/redraws during viewreset Close #5170. * Fix code style * Add a code comment
This commit is contained in:

committed by
Iván Sánchez Ortega

parent
2b5d401976
commit
67f12ee6e9
@ -31,6 +31,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
L.Canvas = L.Renderer.extend({
|
L.Canvas = L.Renderer.extend({
|
||||||
|
getEvents: function () {
|
||||||
|
var events = L.Renderer.prototype.getEvents.call(this);
|
||||||
|
events.viewprereset = this._onViewPreReset;
|
||||||
|
return events;
|
||||||
|
},
|
||||||
|
|
||||||
|
_onViewPreReset: function () {
|
||||||
|
// Set a flag so that a viewprereset+moveend+viewreset only updates&redraws once
|
||||||
|
this._postponeUpdatePaths = true;
|
||||||
|
},
|
||||||
|
|
||||||
onAdd: function () {
|
onAdd: function () {
|
||||||
L.Renderer.prototype.onAdd.call(this);
|
L.Renderer.prototype.onAdd.call(this);
|
||||||
@ -52,6 +62,8 @@ L.Canvas = L.Renderer.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updatePaths: function () {
|
_updatePaths: function () {
|
||||||
|
if (this._postponeUpdatePaths) { return; }
|
||||||
|
|
||||||
var layer;
|
var layer;
|
||||||
this._redrawBounds = null;
|
this._redrawBounds = null;
|
||||||
for (var id in this._layers) {
|
for (var id in this._layers) {
|
||||||
@ -92,6 +104,15 @@ L.Canvas = L.Renderer.extend({
|
|||||||
this.fire('update');
|
this.fire('update');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_reset: function () {
|
||||||
|
L.Renderer.prototype._reset.call(this);
|
||||||
|
|
||||||
|
if (this._postponeUpdatePaths) {
|
||||||
|
this._postponeUpdatePaths = false;
|
||||||
|
this._updatePaths();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_initPath: function (layer) {
|
_initPath: function (layer) {
|
||||||
this._updateDashArray(layer);
|
this._updateDashArray(layer);
|
||||||
this._layers[L.stamp(layer)] = layer;
|
this._layers[L.stamp(layer)] = layer;
|
||||||
|
Reference in New Issue
Block a user