JavaScript jquery animate left percentage off jquery animate left position,jquery animate left to right,jquery

I am trying to move an image (its a picture of a map) inside its container so a specific part of the image(a city) is in the center of its container when a div is clicked. I have this working but the percentage that the image moves to the left is less than what I specify while top works fine.

map is the image container and map-img is the image, bad names I am sorry.

CSS

html, body {
    height: 100%;
    width: 100%;
}
div.scroll {
    position:absolute;
    overflow-y: scroll;
    height: 100%;
    width: 27%;
    position: relative;
    float: right;
}
div.scroll ul{
    list-style-type: none;
}
#map {
    float:left;
    position: absolute;
    height: 100%;
    width: 73%;
    overflow: hidden;
}
#map-img {
    position: relative;
}

HTML

<body>
<div id="map">
    <img id="map-img" src="images/1842map.png" width="1800" height="2338"/>

</div>

<div class="scroll">
    <ul>
        <!-- Define photos here -->
        <li><img class="tooltipper" id="mepkin" title="Mepkin Plantation" src="images/img1.jpg"/></li>
        <li><a target='_blank' href="mepkin-plantation.html"><p class="image-title">Mepkin Plantation</p></a></li>
        <li><img class="tooltipper" id="biggins" title="Biggins Church" src="images/img2.jpg"/></li>
        <li><p class="image-title">Biggins Church</p></li>            
    </ul>
</div>

JQUERY

$(document).ready(function(){ 
    $(".tooltipper").click(function(){
        if ($(this).attr('id')==='mepkin'){
            $("#map-img").animate({top: '-47.8%', left: '-10.8%'});   
        }else if ($(this).attr('id')==='biggins'){
            $("#map-img").animate({top: '3.07%', left: '3.70%'});   

    });
    $("#getalertbutton").click(function(){
        var position = $('#map-img').position();
        var percentLeft = position.left/$(window).width() * 100;
        var percentTop = position.top/$(window).height() *100;
        alert("top: "+percentTop+"   "+"left: "+percentLeft);
    }
});

When I use the alert to get the percentage that map-img has moved it returns:

Mepkin top: -47.79 left: -7.88

Biggins top:-3.069 left:2.69

Since 73% of 10.8 is 7.88 I know that the percentage of the #map container is the culprit, but I do not know what to do to fix this problem.

Answer:1

With this code, my chart is resizing when I drag the window, but not when I press the maximize button on windows or the full screen button on mac. Is this just a chart.js problem? Here is my JS for ...

With this code, my chart is resizing when I drag the window, but not when I press the maximize button on windows or the full screen button on mac. Is this just a chart.js problem? Here is my JS for ...

Here's what I have in mind: Given an array of objects: [ { "name": "Kirk", "count": 1 }, { "name": "Spock", "count": 1 }, { "name": "Kirk",...

Here's what I have in mind: Given an array of objects: [ { "name": "Kirk", "count": 1 }, { "name": "Spock", "count": 1 }, { "name": "Kirk",...

  1. remove duplicate objects from array javascript
  2. remove duplicate objects from list java
  3. remove duplicate objects from list c#
  4. remove duplicate objects from array javascript es6
  5. remove duplicate objects from list java 8
  6. remove duplicate objects from array lodash
  7. remove duplicate objects from list python
  8. remove duplicate objects from array java
  9. remove duplicate objects in arraylist java
  10. remove duplicate objects from arraylist
  11. remove duplicate objects from array swift 4
  12. remove duplicate objects from arraylist in java 8
  13. remove duplicate objects from array javascript reduce
  14. remove duplicate objects from array typescript
  15. remove duplicate objects from array php
  16. remove duplicate objects from list
  17. remove duplicate objects from array react
  18. remove duplicate objects in array js
  19. remove duplicate objects from array jquery
  20. remove duplicate objects from array c#

Take a look at the code below: var pocket = { cash: 1000, showCash: function() { return this.cash; } }; var thomas = { name: "Thomas", work: ...

Take a look at the code below: var pocket = { cash: 1000, showCash: function() { return this.cash; } }; var thomas = { name: "Thomas", work: ...

I'm trying to write a pretty simple app: I have some games (say chess, tictactoe... whatever), and there are several boards of each game. I want to show a list of games, and then show a list of boards ...

I'm trying to write a pretty simple app: I have some games (say chess, tictactoe... whatever), and there are several boards of each game. I want to show a list of games, and then show a list of boards ...