mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-13 05:48:36 +03:00
Adjust dimensions of sites-layer innarrative mode
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import {
|
||||
areEqual,
|
||||
isNotNullNorUndefined
|
||||
} from '../utilities';
|
||||
import { isNotNullNorUndefined } from '../utilities';
|
||||
import hash from 'object-hash';
|
||||
import 'leaflet-polylinedecorator';
|
||||
|
||||
export default function(lMap, svg, g, newApp, ui, methods) {
|
||||
export default function(lMap, svg, newApp, ui) {
|
||||
|
||||
const app = {
|
||||
selected: [],
|
||||
@@ -15,45 +12,6 @@ export default function(lMap, svg, g, newApp, ui, methods) {
|
||||
// Icons for markPoint flags (a yellow ring around a location)
|
||||
const eventCircleMarkers = {};
|
||||
|
||||
function getSVGBoundaries() {
|
||||
const mapNode = d3.select('.leaflet-map-pane').node();
|
||||
if (mapNode === null) return { transformX: 0, transformY: 0 };
|
||||
|
||||
// We'll get the transform of the leaflet container,
|
||||
// which will let us offset the SVG by the same quantity
|
||||
const transform = window
|
||||
.getComputedStyle(mapNode)
|
||||
.getPropertyValue('transform');
|
||||
|
||||
// However getComputedStyle returns an awkward string of the format
|
||||
// matrix(0, 0, 1, 0, 0.56523, 123123), hence this awkwardness
|
||||
return {
|
||||
transformX: +transform.split(',')[4],
|
||||
transformY: +transform.split(',')[5].split(')')[0]
|
||||
}
|
||||
}
|
||||
|
||||
function updateSVG() {
|
||||
const boundingClient = d3.select(`#${ui.dom.map}`).node().getBoundingClientRect();
|
||||
|
||||
let WIDTH = boundingClient.width;
|
||||
let HEIGHT = boundingClient.height;
|
||||
|
||||
// Offset with leaflet map transform boundaries
|
||||
const { transformX, transformY } = getSVGBoundaries();
|
||||
|
||||
svg.attr('width', WIDTH)
|
||||
.attr('height', HEIGHT)
|
||||
.attr('style', `left: ${-transformX}px; top: ${-transformY}px`);
|
||||
}
|
||||
|
||||
lMap.on("zoomend viewreset moveend", updateSVG);
|
||||
|
||||
|
||||
/*
|
||||
* INTERACTIVE FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Removes the circular ring to mark a particular location
|
||||
*/
|
||||
@@ -103,15 +61,11 @@ export default function(lMap, svg, g, newApp, ui, methods) {
|
||||
* Updates displayable data on the map: events, coevents and paths
|
||||
*/
|
||||
function update(newApp) {
|
||||
updateSVG();
|
||||
const isNewAppProps = (hash(app) !== hash(newApp));
|
||||
|
||||
if (isNewAppProps) {
|
||||
if (hash(app) !== hash(newApp)) {
|
||||
app.selected = newApp.selected;
|
||||
app.highlighted = newApp.highlighted;
|
||||
renderSelectedAndHighlight();
|
||||
}
|
||||
|
||||
if (isNewAppProps) renderSelectedAndHighlight();
|
||||
}
|
||||
|
||||
function renderSelectedAndHighlight () {
|
||||
|
||||
Reference in New Issue
Block a user