Ensure only one pane shown at a time, remove unnecessary handlers

This commit is contained in:
Bryan Housel
2017-11-28 23:21:52 -05:00
parent 2e2dd5f025
commit 17809545c6
3 changed files with 27 additions and 21 deletions
+9 -10
View File
@@ -17,6 +17,8 @@ import { svgIcon } from '../svg';
import { uiBackgroundOffset } from './background_offset';
import { uiCmd } from './cmd';
import { uiDisclosure } from './disclosure';
import { uiHelp } from './help';
import { uiMapData } from './map_data';
import { uiMapInMap } from './map_in_map';
import { uiTooltipHtml } from './tooltipHtml';
import { utilDetect } from '../util/detect';
@@ -346,10 +348,9 @@ export function uiBackground(context) {
_shown = show;
if (show) {
selection
.on('mousedown.background-inside', function() {
d3_event.stopPropagation();
});
uiMapData.hidePane();
uiHelp.hidePane();
update();
pane
.style('display', 'block')
@@ -358,9 +359,6 @@ export function uiBackground(context) {
.duration(200)
.style('right', '0px');
pane.selectAll('.layer')
.call(setTooltips);
} else {
pane
.style('display', 'block')
@@ -371,9 +369,6 @@ export function uiBackground(context) {
.on('end', function() {
d3_select(this).style('display', 'none');
});
selection
.on('mousedown.background-inside', null);
}
}
}
@@ -468,6 +463,10 @@ export function uiBackground(context) {
d3_select(document)
.call(keybinding);
uiBackground.hidePane = hidePane;
uiBackground.togglePane = togglePane;
uiBackground.setVisible = setVisible;
}
return background;
+10 -4
View File
@@ -9,7 +9,9 @@ import marked from 'marked';
import { t, textDirection } from '../util/locale';
import { svgIcon } from '../svg';
import { uiCmd } from './cmd';
import { uiBackground } from './background';
import { uiIntro } from './intro';
import { uiMapData } from './map_data';
import { uiShortcuts } from './shortcuts';
import { uiTooltipHtml } from './tooltipHtml';
import { tooltip } from '../util/tooltip';
@@ -278,14 +280,15 @@ export function uiHelp(context) {
shown = show;
if (show) {
selection.on('mousedown.help-inside', function() {
return d3_event.stopPropagation();
});
uiBackground.hidePane();
uiMapData.hidePane();
pane.style('display', 'block')
.style('right', '-500px')
.transition()
.duration(200)
.style('right', '0px');
} else {
pane.style('right', '0px')
.transition()
@@ -294,7 +297,6 @@ export function uiHelp(context) {
.on('end', function() {
d3_select(this).style('display', 'none');
});
selection.on('mousedown.help-inside', null);
}
}
}
@@ -449,6 +451,10 @@ export function uiHelp(context) {
d3_select(document)
.call(keybinding);
uiHelp.hidePane = hidePane;
uiHelp.togglePane = togglePane;
uiHelp.setVisible = setVisible;
}
return help;
+8 -7
View File
@@ -8,7 +8,9 @@ import { d3keybinding as d3_keybinding } from '../lib/d3.keybinding.js';
import { svgIcon } from '../svg';
import { t, textDirection } from '../util/locale';
import { tooltip } from '../util/tooltip';
import { uiBackground } from './background';
import { uiDisclosure } from './disclosure';
import { uiHelp } from './help';
import { uiTooltipHtml } from './tooltipHtml';
@@ -26,7 +28,6 @@ export function uiMapData(context) {
var _featureList = d3_select(null);
function showsFeature(d) {
return context.features().enabled(d);
}
@@ -407,12 +408,10 @@ export function uiMapData(context) {
_shown = show;
if (show) {
uiBackground.hidePane();
uiHelp.hidePane();
update();
selection.on('mousedown.map_data-inside', function() {
return d3_event.stopPropagation();
});
pane
.style('display', 'block')
.style('right', '-300px')
@@ -430,8 +429,6 @@ export function uiMapData(context) {
.on('end', function() {
d3_select(this).style('display', 'none');
});
selection.on('mousedown.map_data-inside', null);
}
}
}
@@ -501,6 +498,10 @@ export function uiMapData(context) {
d3_select(document)
.call(keybinding);
uiMapData.hidePane = hidePane;
uiMapData.togglePane = togglePane;
uiMapData.setVisible = setVisible;
}
return mapData;