added compass button and coupled its transform:rotate style attribute with the POV heading value

This commit is contained in:
Balázs Vigh 2021-04-28 20:33:17 +02:00
parent 3d52c967b6
commit e33d8c02e9
3 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<polygon id="needleNorth" points="50,0 33,50 66,50" style="fill:red;stroke:black;stroke-width:1" />
<polygon id="needleSouth" points="50,100 33,50 66,50" style="fill:white;stroke:black;stroke-width:1" />
Sorry, your browser does not support inline SVG.
</svg>

After

Width:  |  Height:  |  Size: 328 B

View File

@ -382,6 +382,10 @@
// needs to be set visible after the show guess map hid it in mobile view // needs to be set visible after the show guess map hid it in mobile view
document.getElementById("navigation").style.visibility = 'visible'; document.getElementById("navigation").style.visibility = 'visible';
// update the compass
const heading = Game.panorama.getPov().heading;
document.getElementById("compass").style.transform = "rotate(" + heading + "deg)";
}, },
handleErrorResponse: function (error) { handleErrorResponse: function (error) {
@ -858,6 +862,9 @@
Game.panorama.addListener('pov_changed', function () { Game.panorama.addListener('pov_changed', function () {
Game.rewriteGoogleLink(); Game.rewriteGoogleLink();
const heading = Game.panorama.getPov().heading;
document.getElementById("compass").style.transform = "rotate(" + heading + "deg)";
}); });
if (COOKIES_CONSENT) { if (COOKIES_CONSENT) {

View File

@ -60,6 +60,14 @@
</div> </div>
</div> </div>
<div id="navigation"> <div id="navigation">
<div id="compass" class="navigationItem">
<span>
<img src="<?= $_ENV['STATIC_ROOT'] ?>/img/circle_background.svg?rev=<?= REVISION ?>" alt="Circle Background" class="circleBackground" />
</span>
<span>
<img src="<?= $_ENV['STATIC_ROOT'] ?>/img/compass.svg?rev=<?= REVISION ?>" alt="compass icon" class="navigationIcon" />
</span>
</div>
<div id="returnToStart" class="navigationItem"> <div id="returnToStart" class="navigationItem">
<span> <span>
<img src="<?= $_ENV['STATIC_ROOT'] ?>/img/circle_background.svg?rev=<?= REVISION ?>" alt="Circle Background" class="circleBackground" /> <img src="<?= $_ENV['STATIC_ROOT'] ?>/img/circle_background.svg?rev=<?= REVISION ?>" alt="Circle Background" class="circleBackground" />