mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Avoid asking DOM if layers are classed disabled in map.editable
`map.editable` is hot code because it's called frequently by the `isHiddenX` tests in `features.js`. It's much more efficient to just ask the osm layer whether it is enabled, than to use D3 to find that layer in the DOM and check whether it's classed `disabled`
This commit is contained in:
@@ -887,16 +887,16 @@ export function rendererMap(context) {
|
||||
|
||||
|
||||
map.editable = function() {
|
||||
var osmLayer = surface.selectAll('.data-layer.osm');
|
||||
if (!osmLayer.empty() && osmLayer.classed('disabled')) return false;
|
||||
var layer = context.layers().layer('osm');
|
||||
if (!layer || !layer.enabled()) return false;
|
||||
|
||||
return map.zoom() >= context.minEditableZoom();
|
||||
};
|
||||
|
||||
|
||||
map.notesEditable = function() {
|
||||
var noteLayer = surface.selectAll('.data-layer.notes');
|
||||
if (!noteLayer.empty() && noteLayer.classed('disabled')) return false;
|
||||
var layer = context.layers().layer('notes');
|
||||
if (!layer || !layer.enabled()) return false;
|
||||
|
||||
return map.zoom() >= context.minEditableZoom();
|
||||
};
|
||||
|
||||
@@ -48,9 +48,9 @@ export function svgOsm(projection, context, dispatch) {
|
||||
}
|
||||
|
||||
|
||||
drawOsm.enabled = function(_) {
|
||||
drawOsm.enabled = function(val) {
|
||||
if (!arguments.length) return enabled;
|
||||
enabled = _;
|
||||
enabled = val;
|
||||
|
||||
if (enabled) {
|
||||
showLayer();
|
||||
|
||||
Reference in New Issue
Block a user