Avoid reflow caused by restriction editor checking its dimensions

This commit is contained in:
Bryan Housel
2018-11-10 00:40:45 -05:00
parent 05a5563a41
commit 4a3d5e2316
2 changed files with 14 additions and 3 deletions

View File

@@ -235,7 +235,14 @@ export function uiFieldRestrictions(field, context) {
var filter = utilFunctor(true);
var projection = geoRawMercator();
var d = utilGetDimensions(selection);
// Reflow warning: `utilGetDimensions` calls `getBoundingClientRect`
// Instead of asking the restriction-container for its dimensions,
// we can ask the #sidebar, which can have its dimensions cached.
// width: calc as sidebar - padding
// height: hardcoded (from `80_app.css`)
// var d = utilGetDimensions(selection);
var sdims = utilGetDimensions(d3_select('#sidebar'));
var d = [ sdims[0] - 50, 370 ];
var c = geoVecScale(d, 0.5);
var z = 22;

View File

@@ -390,8 +390,12 @@ export function uiInit(context) {
ui.onResize = function(withPan) {
var map = context.map();
var content = d3_select('#content');
var mapDimensions = utilGetDimensions(content, true);
// Recalc dimensions of map and sidebar.. (`true` = force recalc)
// This will call `getBoundingClientRect` and trigger reflow,
// but the values will be cached for later use.
var mapDimensions = utilGetDimensions(d3_select('#content'), true);
utilGetDimensions(d3_select('#sidebar'), true);
if (withPan !== undefined) {
map.redrawEnable(false);