Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="section-content-djax" class="updatable-w-djax"><!-- START section-content-djax  -->

  <div id="section-content-print" class="row small-collapse medium-collapse large-collapse justifyContent handwritten"> <!-- START ROW  -->

    <div id="modalPrintAdvil" class="boxFrameOuter small-12 medium-6 large-4 columns healthcare">
      <div id="boxFrame1" class="boxFrame">
        <div class="innerFrame1"></div>
        <div class="innerFrame2"></div>
        <div class="innerFrame3"></div>
        <span class="clientLabel handwritten"><p>Advil</p></span>

        <img class="fadeMe" src="http://hainis.net/dev/assets/img/modalPrintAdvil1a.jpg" alt="Advil Blah Blah Blah Ad">
      </div>
    </div>

  </div><!-- END ROW  -->

</div><!-- END section-content-djax  -->

<!-- END Print Page Contnet ======================================= -->
              
            
!

CSS

              
                /* *************************************************************** */
/* ******************* Custom Styles v00.53.56 ******************* */
/* *************************************************************** */


/* ***************************************** */
/* *************** Font Stack ************** */
/* ***************************************** */


.handwritten {
    font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif;
    font-weight: 400;
    font-style: normal;
    color: #000;
}

.handwritten p {
    font-size: 1em;}

      /* ********************************* */
      @media all and (max-height: 200px) {
      .handwritten p {
        font-size: .75em;
        /* line-height: .85; */        
        }
      }

      @media all and (min-height: 201px) and (max-height: 400px) {
      .handwritten p {
        font-size: .85em;
         /* line-height: .95; */         
        }
      }

      @media all and (min-height: 401px) and (max-height: 600px) {
      .handwritten p {
        font-size: .90em;
        /* line-height: 1.05; */
        }
      }

      @media all and (min-height: 601px) {
      .handwritten p {
        font-size: 1.0em;
        /* line-height: 1.10; */
        }
      }


/* *********************** */
/* ***** Main Styles ***** */
/* *********************** */

body {
  overflow: hidden;
  margin: 0;
  padding: 0;
  background-color: #afafaf; 
}


.texture-paper-bkg {
  position: fixed;
  position: -ms-device-fixed;
  width: 100%;
  height: 100%;
  background-image: url('http://hainis.net/dev/assets/img/seamless-paper-warm-gray-v3.jpg');
  background-size: 50%; /* Background Size adjusted by Media Query - See .overlay class */
  background-repeat: repeat;
  background-position: top left;
}




/* ******************************************************* */
/* ************** Section Content Container ************** */
/* ******** Dynamically Loaded By GSAP - Pjax/dJax ******* */
/* ******************************************************* */

.hideMe {
  display: none;
}


.showMe {
  display: block;
}


#closeSection {
  position: fixed;
  position: -ms-device-fixed;
  display: none; /* GreenSock Sets Display */
  cursor: pointer;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  margin-top: 5px;
  margin-right: 7px;
  background-image: url('http://hainis.net/dev/assets/img/closeButton-base.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: none;
  border: none;
}

.closeSectionModal {
    position: fixed;
    position: -ms-device-fixed;
    display: block;
    opacity: 1;
    cursor: pointer;
    top: 0;
    right: 0;
    border: 1px solid #114469;
    color: #114469;
     -webkit-transition: background-color .25s ease-out;
    -moz-transition: background-color .25s ease-out;
    -o-transition: background-color .25s ease-out;
    transition: background-color .25s ease-out;
    z-index: 999;
}


#closeSection:hover, 
#closeSection:focus, 
#closeSection:active {
  background-image: url('http://hainis.net/dev/assets/img/closeButton-hover.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
}
      
      @media all and (min-width: 401px) {
      #closeSection {
          margin-top: 8px;
          margin-right: 10px;
          width: 70px;
          height: 70px;
        }
      }


      @media all and (max-width: 400px) {
      .closeSectionModal {
          margin-top: 18px;
          margin-right: 19px;
          width: 37px;
          height: 37px;
          font-size: 2em;
          padding-bottom: .16em;
        }
      .modalNav ul{
          margin-top: 23px;
        }
      .modalNav ul li {
          margin-right: 10px;
        }
      }


      @media all and (min-width: 401px) {
      .closeSectionModal {
          margin-top: 25px;
          margin-right: 25px;
          width: 39px;
          height: 39px;
          font-size: 1.75em;
          padding-bottom: .16em;
        }
      .modalNav ul{
          margin-top: 23px;
        }
      .modalNav ul li {
          margin-tright: 15px;
        }
      }


.closeSectionModal:hover, 
.closeSectionModal:focus, 
.closeSectionModal:active {
  background-color: #08385d;
  border: 1px solid #C00000;
}

#section-content-djax {
  position: absolute;
  display: block; /* GreenSock Sets Display */
  width: 100vw;
  height: 100vh;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: scroll;
  /* background-image set by GreenSock */
  background-size: 50%;
  background-repeat: repeat;
  background-position: top left;
}



/* *************************************************** */
/* ************** Box Frames For Photos ************** */
/* *************************************************** */
.justifyContent {
  text-align: center;
  font-size: 1em; /* IE 9 & 10 don't like font-size: 0; */
}

.justifyContent div {
  /* width: 20%; */
  /* height: auto; */
  display: inline-block;
}


.justifyContent:after {
  content: '';
  width: 100%; /* Ensures there are at least 2 lines of text, so justification works */
  display: inline-block;
}

.justifyContent div {
  float: none;
}

#selectPrintAdvil {
  cursor: pointer;
}

.clientLabel {
  display: block;
  opacity: 1;
}


.boxFrame {
  position: relative;
  background-color: none;
  cursor: pointer;
  width: 100%;
  height: auto;
  padding: 3%;
  /* background-image: url('SET BY GSAP'); */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  /* background-color: white; */
  max-width: 1150px;
  line-height: 0;
}


.innerFrame1 {
  position: absolute;
  background-color: none;
  /* cursor: pointer; */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('http://hainis.net/dev/assets/img/boxFrame.gif');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: none;
}

.innerFrame2,
.innerFrame3 {
  position: absolute;
  background-color: none;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* background-image: url('SET BY GSAP'); */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: none;
}


.boxFrame span {
  position: absolute;
  top: 0;
  right: 0;
  background-color: black;
  height: 1.5em;
  margin-top: .20em;
  margin-right: .12em;
  padding-top: .075em;
  padding-bottom: .25em;
  padding-left: .35em;
  padding-right: .35em;
  transform: skewX(-10deg);
}



      /* ********************************* */
      @media all and (max-width: 40em) {
      .clientLabel {
        height: 1.7em;
        line-height: 1.7;
        }
      }

      @media all and (max-width: 40em) and (max-height: 40em) {
      .clientLabel {
        height: 1.2em;
        line-height: 1.7;
        }
      }

      @media all and (max-width: 40em) and (max-height: 64em) {
      .clientLabel {
        height: 1.5em;
        line-height: 1.5;
        }
      }

      @media all and (min-width: 40.063em) and (max-width: 64em) {
      .clientLabel {
        height: 1.5em;
        line-height: 1.5;
        }
      }

      @media all and (min-width: 90.063em) {
      .clientLabel {
        height: 1.5em;
        line-height: 1.5;
        }
      }


.boxFrame p {
  text-align: center;
  -webkit-text-stroke: .25px white;
  color: white;
  text-shadow:
   -.25px -.25px 0 #000,  
    .25px -.25px 0 #000,
    -.25px .25px 0 #000,
     .25px .25px 0 #000;
  letter-spacing: .05em;
}

.justifyContent .columns:last-child:not(:first-child) {
    float: none;
}

      /* ********************************* */      
      @media all and (max-width: 40em) {
      .boxFrameOuter {
        width: 100%;
        margin: auto;
        margin-bottom: .75rem;
        }
      }

      @media all and (min-width: 40.063em) and (max-width: 90em) {
      .boxFrameOuter {
        width: 45%;
        margin-right: .75rem;
        margin-bottom: .75rem;
        }
      }

      @media all and (min-width: 90.063em) {
      .boxFrameOuter {
        width: 31%;
        margin-right: .75rem;
        margin-bottom: .75rem;
        }
      }


/* *********************************************** */
/* ***** User Selected Client Work and Modal ***** */
/* *********************************************** */

.overlay {
  display: none;  /* GreenSock Sets Display */
  position: fixed;
  position: -ms-device-fixed;
  width: 100%;
  height: 100%;
  background-image: url('http://hainis.net/dev/assets/img/seamless-paper-texture-drk-blu.jpg');
  background-size: 50%; /* Note Media query controls size - see texture-paper-bkg class in Main Styles */
  background-repeat: repeat;
  background-position: top left;
  /* background-color: #090E38; */
  z-index: 101;
}

          @media all and (min-width: 900px) and (max-width: 1000px) {
          #section-content-djax,
          .overlay,
          .texture-paper-bkg {
            background-size: 30%;
            }
          }

          @media all and (min-width: 1001px) {
          #section-content-djax,
          .overlay,
          .texture-paper-bkg {
            background-size: 20%;
            }
          }

.clone {
  position: absolute;
  /* display: none; */
  /* opacity: 0; */
 /*  padding: 0; */
  z-index: 102;
}



a {
    text-decoration: none;
}

.modalNav {
    position: fixed;
    top: 50%;
    left: 0;
    width: 45px;
    transform: translateY(-50%);
    z-index: 999;
}

.modalNav ul {
    list-style: none;
    text-align: left;
}

.modalNav ul li {
    display: block;
}

.modalNav ul li:last-child {
    margin-right: 0;
}

#back-to-tutorial {
    margin-left: 100px;
}

.modalNav a {
    position: relative;
    top: 0;
    font-weight: normal;
    text-align: center;
    border: 1px solid #114469;
    border-radius: 50%;
    background-color: none;
    color:#114469;
}


.modalNav a.active {
  background-color: #08385d;
  border: 1px solid #C00000;
}

      @media all and (max-width: 400px) {
      .modalNav ul{
          margin-top: 18px;
        }
      .modalNav ul li {
          margin-right: 10px;
          margin-bottom: 10px;
        }
      .modalNav a {
          padding: 0px 6px;
          font-size: 14px;
        }
      }


      @media all and (min-width: 401px) {
      .modalNav ul{
          margin-top: 23px;
        }
      .modalNav ul li {
          margin-right: 15px;
          margin-bottom: 15px;
        }
      .modalNav a {
          padding: 0px 8px;
          font-size: 18px;
        }
      }

.slides-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 10;
}

.slide {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.slide .centered {
    position: absolute;
    display: block;
    opacity: 1;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: auto;
    transform: translate(-50%, -50%);
    max-width: 1150px;
    background-image: none;
    padding: 1.5rem;
}
      /* ********************************* */   

      @media all and (max-width: 40em) {
      /* .clone, */ 
      .clonePadding,
      .slide .centered {
        padding: 14%;
        }
      }

      @media all and (min-width: 40.063em) and (max-width: 90em) {
      /* .clone, */
      .clonePadding,
      .slide .centered {
        padding: 10%;
        }
      }

      @media all and (min-width: 90.063em) {
      /* .clone, */
      .clonePadding,
      .slide .centered {
        padding: 0%;
        }
      }


.go-prev, .go-next {
    cursor: pointer;
    font-weight: bold;
    text-decoration: underline;
}


a.slide:link,
.slide p {
  font-family: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
  font-weight: 400;
  font-style: normal;
  color: #4f81a5;
  padding-left: 3%;
  padding-right: 3%;
  text-align: left;
  line-height: 1.5;
}

a.slide:visited {
  color: #325A73;
}

a.slide:hover {
  color: #55788C;
}

.slide h1,
.slide h2,
.slide h3 {
  color: #4f81a5;
  line-height: 1;
  margin-bottom: 0; 
  padding-bottom: 0 !important;
  text-align: left;
  padding: 3%;
}

.slide h1 {
  font-size: 2em;
}
              
            
!

JS

              
                // ==================================================================
// ============== Section Content Javascript v00.53.56 ==============
// ==================================================================

"use strict";

//  Modal Vars   =============================================================================
var vw = $(window).width();
var vh = $(window).height();

var body = $("body");

var boxFrame = $(".boxFrame");
var boxFrameOuter = $(".boxFrameOuter");

var closeModal = $("#closeModal");

var overlay = $("<div class='overlay updatable-w-djax'></div>");
var overlayDiv = $(".overlay");

var clone = null;
var target = null;
var currentOriginalLocation = null;
var tlUserSelected = null; // Modal TweenMax Timeline
var cloned1 = $("#cloned1");
var currentSelect = null;
var paddingCalc = null;
var cloneVw = null;
var cloneVwPercent = null;
var rectWidth = null;
var scaleValue = null;

var $this = $(this);

var closeSectionModal = $(".closeSectionModal");

// Click Function for Modal Selection
boxFrame.on("click", function(e) {
  if (!e) {
    var e = window.event;
  }
  var ele = e.target || e.srcElement;

  // pass the var e value to openTile
  openTile(e);
  console.log("boxFrameOuter Clicked / Cloned");

}); // END on Click

$(window).resize(resizeModal);

function resizeModal(resizeModal) {

  // If there's a timeline, rebuild it
  if (tlUserSelected) {
    var progress = tlUserSelected.progress();
    var reversed = tlUserSelected.reversed();
    // tlUserSelected.kill();
    tlUserSelected.seek(0).clear();
    buildTimelineUserSelected(progress, reversed);
  } // END if

}; // END Window Resize


// START - Add media query   =================================================================
// Gets passed into tween

 var mediaQueryClone = window.matchMedia("(max-width: 40em)");
    if (mediaQueryClone.matches) {      
      paddingCalc = "14%";
      cloneVw = ".82";
      cloneVwPercent = "82%";
    };

 var mediaQueryClone = window.matchMedia("(min-width: 40.063em) and (max-width: 90em)");
    if (mediaQueryClone.matches) {      
      paddingCalc = "10%";
      cloneVw = ".80";
      cloneVwPercent = "80%";
    };

 var mediaQueryClone = window.matchMedia("(min-width: 90.063em)");
    if (mediaQueryClone.matches) {      
      paddingCalc = "0%";
      cloneVw = "1.0";
      cloneVwPercent = "100%";
    };




// ===========================================================================
// ======== Client Work Selectd by User Modal Timeline and Functions =========
// ===========================================================================

function buildTimelineUserSelected(progress, reversed) {

var vw = $(window).width();
var vh = $(window).height();

var rect = getPosition(target[0]);
 
var clientLabel = $(".clone").find("span");
var innerFrame1 = $(".clone").find(".innerFrame1");
var innerFrame2 = $(".clone").find(".innerFrame2");
var innerFrame3 = $(".clone").find(".innerFrame3");
var fadeMe = $(".clone").find(".fadeMe");
var boxFrame = $(".clone").find(".boxFrame");

var cloneScale = vw / rectWidth;
// var cloneScale = (vw * cloneVw) / rectWidth;

scaleValue;
if(cloneScale > 3) {
    scaleValue = 3;
} else { 
  scaleValue = scaleValue; 
};

var image1b = "url(http://hainis.net/dev/assets/img/" + currentSelect + "1b.jpg)";
var image1c = "url(http://hainis.net/dev/assets/img/" + currentSelect + "1c.jpg)";


  TweenMax.set(closeSectionModal, { className: "closeSectionModal", opacity: 1, display: "block" });
  TweenMax.set(overlay, { opacity: 0, display: "none" });
  TweenMax.set(boxFrame, { cursor: "default" });
  TweenMax.set(innerFrame1, { opacity: 1, display: "block" });
  

  TweenMax.set(clientLabel, { opacity: 1, display: "block" });
  
  TweenMax.set(clone, rect, { opacity: 1, display: "block", maxWidth: "100vw", padding: 0 });
  

  tlUserSelected = new TimelineMax({ onReverseComplete: removeClone })
          
          .to(overlay, .75, { 
              opacity: 1, 
              display: "block",
               onStart: function() {
                  // Do Something
                     
               }, // END onStart
               onComplete: function() {
                  // Do Something

               }, // END onComplete
               onReverseComplete: function () {
                  // Remove Clone From DOM
                  clone.remove();
               
                  TweenMax.set(boxFrame, { cursor: "pointer" });

                }, // END onReverseComplete
            }, 0, "overlay") // END overlay
          
  

  
  
          .to(clone, 1.0, { 
            opacity: 1, 
            display:"block",
    
            // Using this CSS code here creates an odd arc path
            // I beilieve it is due to the render/calculation order.
            // Instead of a direct, straight line, to the final centered position
            // it moves left and right before centering properly
            
            left: "50%", 
            top: "50%",        
            xPercent: "-50%",
            yPercent: "-50%",
            transform: "translate(0%, -50%)",
            // width: cloneVwPercent,
            scale: cloneScale,
            height: "auto",
            maxWidth: "1150px",
            // maxWidth: "1150px",
            // padding: paddingCalc,
            autoRound: false,
            // ease:Power2.easeInOut, // ORIGINAL Ease In/Out
            ease:Power0.easeNone,
            onComplete: function() {
                  // Do Something
              $('#slide-1').css("padding", paddingCalc );
              /*
                  TweenMax.set(clone, { opacity: 1, 
                                       display: "block", 
                                       className:"clone clonePadding", 
                                       width: "100%",
                                       transform: "translate(0%, -50%)",
                                       xPercent: "-50%",
                                       yPercent: "-50%",
                                       padding: paddingCalc
                                      });
                                      */
                              
               }, // END onComplete
            onReverseComplete: function () {
                  // Remove Clone From DOM
                  $(".clone").css("display", "none");
                  $(".clone").remove();

                }, // END onReverseComplete
             }, .25, "lineArt") // END clone
             
             

          .to(innerFrame1, 0.25, { opacity: 0, display: "none" }, "overlay-=0.75")
          .to(clientLabel, 0.25, { opacity: 0, display: "none" }, "overlay-=0.75")
          .to(boxFrame, 0.5, { padding: "0" }, 0)
          .to(closeSectionModal, 0.5, { className: "closeSectionModal", opacity: 1, display: "block" }, .25)
          .to(innerFrame2, 1.0, { opacity: 1 }, "lineArt+=0.25")
          .to(innerFrame3, 1.0, { opacity: 1 }, "-=0.15")
          // .to(innerFrame2, .003, { opacity: 0 }, "-=0")
          // .to(fadeMe, .003, { opacity: 0 }, "-=0")
          .progress(progress || 0)
          .reversed(reversed || false);


} // END - buildTimelineUserSelected

function openTile(e) {
  // "e" value is passed in from the on click function 

  target = $(e.target).closest('.boxFrameOuter'); // solved targeting issue by using .closest vs .parent

  // redefine currentSelect var on a global level for dynamic URL
  // NOTE: by NOT using the keyword var here it will redefine the Global value
  // when you use "var" within a function it keeps it local/within the function
  currentSelect = $(e.target).closest('.boxFrameOuter').attr('id');
  console.log( "currentSelect value = " + currentSelect );

  // Set Var number for Clone ID formual
  var cloneCount = 1;

  // Clone and set Unique ID so it is valid HTML with no conflicts
  clone = target.clone(false).prop('id', currentSelect + cloneCount++ ).addClass('clone').css({ "cursor": "default", "padding": "0" });



  // (false) is no Deep Clone.
  // if you want Deep Clone (which clones styles ID and Class names 
  // as well as and all child elements) set to (true) and 
  // IMPORTANT!!! If you use the Deep Clone method make sure ID of the cloned element is unique!


  var urlLink = "assets/modals/" + currentSelect + ".html";
  
  body.append(overlay).promise().done(function() {

    // Load external HTML page via AJAX method         
    $.ajax({
        async: true,
        type:'get',
        url: 'https://codepen.io/jh-thank-you/pen/rjqNaY.html',
        cache:false,
        dataType: 'html',
        start: function()
        {

        }, // END start
        success:function(data)
        {
            
            $('.overlay').html(data).promise().done(function() {
                
              // Create Clone inside Modal Slide Container
             $('#slide-1').append(clone);

          }); // END Promise
        }, // END success
        complete: function() {
                  
                    // Make Clone Div Unique ID
                    $(".clone").find(".boxFrame").attr("id", "clone-1");
          
                    // Load Script
                    $.getScript( "https://codepen.io/jh-thank-you/pen/rjqNaY.js" ).promise().done(function() {
                    // Load Script
                     
                        console.log( "ScrollToPlugin and Custom Modal JS loaded" );
                    }); // END Promise
        } // END Complete
    }); // END AJAX
  }); // END Promise Append Overlay
  

  // After the AJAX DOM Elements are created build the timeline and pass the 
  // currentSelect var (for the dynamic url background images) to the timeline
  buildTimelineUserSelected(currentSelect);

    if ($('.clone').length > 1) {
      clone.css("display", "none");
      clone.detach();
      clone.remove();
    } // END if

} // END openTile

function closeTile() {
  // tlUserSelected.reverse();
  TweenMax.to(overlay, 0.75, {
    opacity: 0,
    display: "none",
    onComplete: function() {
      // Remove Clone From DOM
      $(".clone").css("display", "none");
      $(".clone").remove();
      removeClone();

      //kill only tweens, but not delayedCalls or timelines
      TweenMax.killAll(false, true, false, false);

      //kill only delayedCalls
      TweenMax.killAll(false, false, true, false);

    }, // END onReverseComplete
  }, 0);

  console.log("Closed Overlay");
} // END closeTile

function removeClone() {

  overlay.detach();

  // Due to the way the timelines are redrawn with window resize
  // if a user resizes the window and clicks/selects a boxFrame,
  // which launches the overlay Modal timeline, it results in
  // the clone being created several times. The following
  // if/else loop cycles through and clears them out. Also,
  // for some reason the reverse onComplete doesn't change back 
  // the opacity for the labels, it should ve set back to 1 (100%).
  if (clone.length > 0) {
    clone.css("display", "none");
    clone.detach();
    clone.remove();
  } else {
    clone = null;
    // clientLabel.css("opacity", "1");

    // Clear and Kill Timeline
    tlUserSelected.clear();
    tlUserSelected.kill();
  }

  tlUserSelected = null;
  target = null;
  clone = null;

} // END removeClone

function getPosition(element) {

  var body = document.body;
  var root = document.documentElement;
  var rect = element.getBoundingClientRect();

  var scrollTop = window.pageYOffset || root.scrollTop || body.scrollTop || 0;
  var scrollLeft = window.pageXOffset || root.scrollLeft || body.scrollLeft || 0;

  var clientTop = root.clientTop || body.clientTop || 0;
  var clientLeft = root.clientLeft || body.clientLeft || 0;

  return {
    top: Math.round(rect.top + scrollTop - clientTop),
    left: Math.round(rect.left + scrollLeft - clientLeft),
    height: rect.height,
    width: rect.width
  };

} // END getPosition
              
            
!
999px

Console