From 4804497b3c32ceb212ad168aa1d33e2e57039ba6 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Tue, 15 Apr 2025 09:49:16 -0500 Subject: [PATCH] Updated positioning of text --- index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index a360f0c..bfabf6c 100644 --- a/index.js +++ b/index.js @@ -213,9 +213,14 @@ function stateOrDistrictOrLanguage(d) { // const mapWidth = document.getElementById("indiaMap").getAttribute("width") // const mapHeight = document.getElementById("indiaMap").getAttribute("height") -const mapWidth = /*window.innerWidth - */document.querySelector("#svgContainer").offsetWidth * 0.85; +let mapWidth = /*window.innerWidth - */document.querySelector("#svgContainer").offsetWidth * 0.85; // const mapHeight = document.querySelector("#svgContainer").offsetHeight; -const mapHeight = (window.innerHeight - document.querySelector("#svgContainer").getBoundingClientRect().top); +let mapHeight = (window.innerHeight - document.querySelector("#svgContainer").getBoundingClientRect().top); + +if (window.innerWidth <= 768) { + mapWidth *= 1.5; + mapHeight *= 1.5; +} const svg = d3.select("#svgContainer") .append('svg') @@ -288,6 +293,9 @@ function drawMap(world) { if (d.properties.lang_name == "Tamil") { rtv += 20; } + if (d.properties.lang_name == "Kannada" && window.innerWidth <= 768) { + rtv += 15; + } if (d.properties.lang_name == "Maithali") { rtv += 10; } @@ -304,7 +312,9 @@ function drawMap(world) { if (stateOrDistrictOrLanguage(d) == "language") { rtv = projection(d3.geoCentroid(d))[1] if (d.properties.lang_name == "Kannada") { - rtv += 15; + if (window.innerWidth > 768) { + rtv += 10; + } } if (d.properties.lang_name == "Tamil") { rtv -= 20;