Add zoom display
This commit is contained in:
1 parent
5b8e12b2f2
commit
8a0fba67e1
2 files changed
+3
No files matched your search
@@ -211,6 +211,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="footer" class="orange">
|
<div id="footer" class="orange">
|
||||||
|
<div id="zoomLevelDisplay"></div>
|
||||||
Map v0.2 alpha
|
Map v0.2 alpha
|
||||||
<br>
|
<br>
|
||||||
Updated for Game Build 99.3
|
Updated for Game Build 99.3
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ const scaleCullThresholds = [
|
|||||||
// CODE
|
// CODE
|
||||||
const map = document.getElementById('map');
|
const map = document.getElementById('map');
|
||||||
const map_container = document.getElementById('mapContainer');
|
const map_container = document.getElementById('mapContainer');
|
||||||
|
const zoomLevelDisplay = document.getElementById('zoomLevelDisplay');
|
||||||
const styleRoot = document.querySelector(':root');
|
const styleRoot = document.querySelector(':root');
|
||||||
const svgns = map.getAttribute('xmlns');
|
const svgns = map.getAttribute('xmlns');
|
||||||
|
|
||||||
@@ -124,6 +125,7 @@ function updateMapview(navData = {x:0, y:0, scale:1}){
|
|||||||
currentMapNav = navData;
|
currentMapNav = navData;
|
||||||
map.style.transform = `translate(${-navData.x}px, ${-navData.y}px) scale(${navData.scale})`;
|
map.style.transform = `translate(${-navData.x}px, ${-navData.y}px) scale(${navData.scale})`;
|
||||||
if(navData.scale !== previousMapScale){
|
if(navData.scale !== previousMapScale){
|
||||||
|
zoomLevelDisplay.innerHTML = `Zoom: ${Math.round(navData.scale*100)/100}x`;
|
||||||
let dirtyScale = previousMapScale < 0;
|
let dirtyScale = previousMapScale < 0;
|
||||||
for(const cullThreshold of scaleCullThresholds){
|
for(const cullThreshold of scaleCullThresholds){
|
||||||
if(dirtyScale || (previousMapScale < cullThreshold.scale && navData.scale > cullThreshold.scale) || (previousMapScale > cullThreshold.scale && navData.scale < cullThreshold.scale)){
|
if(dirtyScale || (previousMapScale < cullThreshold.scale && navData.scale > cullThreshold.scale) || (previousMapScale > cullThreshold.scale && navData.scale < cullThreshold.scale)){
|
||||||
|
|||||||
Reference in new issue
Block a user