Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

<h1>Focaliser sur une image grand format (Javascript)</h1>
<div class="menuderoulant">
    <li><a href="#">ZONES</a>
          <li><a href="#zone1" class="wdgcoord">zone 1 (Zone à droite haute )</a></li> 
          <li><a href="#zone3" class="wdgcoord">zone 3 (Zone à droite basse)</a></li>
          <li><a href="#zone4" class="wdgcoord">zone 4 (Zone à gauche milieu)</a></li>
          <li><a href="#zone5" class="wdgcoord">zone 5 (Zone à gauche haute)</a></li>
          <li><a href="#zone6" class="wdgcoord">zone 6 (Zone à gauche basse)</a></li>

<div style="width:450px ; height:462px ; border:solid ; border-color:rgba(0,0,0,1.00) ; overflow:auto">
  <img src="" width="1000" height="900"  alt="" usemap="#ImageMap1">
  <map name="ImageMap1"> 
      <!-- Zone à droite haute -->
      <area id="zone1" shape="poly" coords="365,307,471,463,826,291,752,119" href="#"> 
      <!-- Zone à droite basse -->
      <area id="zone3" shape="poly" coords="611,496,564,903,990,757,879,421" href="#">
      <!-- Zone à gauche milieu -->
      <area id="zone4" shape="poly" coords="57,380,112,596,272,541,237,404" href="#">
      <!-- Zone à gauche haute -->
      <area id="zone5" shape="poly" coords="30,179,112,341,304,305,216,192" href="#">
      <!-- Zone à gauche basse -->
      <area id="zone6" shape="poly" coords="112,656,140,884,444,860,438,578" href="#">
              /* //////////////////////////////////////////////
Plus d'informations liées à la solution  : 

Toutes le fonctions ci-dessous peuvent être optimisées
elles sont même volontairement non optimisées
Elles sont là juste pour vous présenter le concept à vous de les améliorer 
var wdgCoord = {
    var aLinks = document.getElementsByClassName(;
    for(var i=0; i< aLinks.length;i++){
      aLinks[i].addEventListener('click', this.getAncre.bind(this));
    var oLink = oEvent.currentTarget,
        sHash = oLink.hash.replace("#",''),
        oArea = document.getElementById(sHash),
        oPos = {x:0,y:0},
    if(oArea && oArea.tagName=="AREA"){
      oPos = this.getCoordonne(oArea);
      sUsemap = "#";
      aImgTmp = [];
      aImg =  aImgTmp.filter(function(img){ if(img.useMap == sUsemap){return img;} } );
        this.setScroll(aImg[0], oPos);
    //console.log(sUsemap, oPos,  aImg);
  setScroll : function (oImg, oPos){
    var oConteneur = oImg.parentElement, 
        height = oConteneur.clientHeight,
        width = oConteneur.clientWidth; ;
    oConteneur.scrollTop = oPos.y-(height/2);
    oConteneur.scrollLeft = oPos.x-(width/2); 
  getCoordonne : function (oMap){
    //On part du principe ou c'est toujours des shape="poly" 
    var aPoint = oMap.coords.split(","),
        aXPoint = [],
        aYPoint = [],
        iXMin , iXMax, iYMin, iYMax 
    for(var i=0; i< aPoint.length;i++){
      var iPoint = aPoint[i];
    iXMin = Math.min.apply(null,aXPoint);
    iXMax = Math.max.apply(null,aXPoint);
    iYMin = Math.min.apply(null,aYPoint);
    iYMax = Math.max.apply(null,aYPoint);
    console.log(aPoint, aXPoint, aYPoint, iXMin, iXMax, iYMin, iYMax );
    var iPosX = iXMin+((iXMax-iXMin)/2);
    var iPosY = iYMin+((iYMax-iYMin)/2);
    return {x:iPosX,y:iPosY};


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.