Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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 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.

HTML

              
                <div class="outer">
  <img src="http://opsundbay.com/Media/collection/20010104/20010104_hd.jpg"
</div>
              
            
!

CSS

              
                body{width:100%;margin:0;padding:0;overflow-x:hidden;}
img{position:absolute;top:0;left:0;margin:0;padding:0;}

.outer{position:fixed;width:100%;height:auto;}

.outer img{width:100%;height:auto;}
              
            
!

JS

              
                //Get the div
var _imgDiv = document.getElementsByClassName("outer")[0];

//Vars
var _sw = 0, _sh = 0, _scrollAmount = 0, _windowScrollY = 0, _zoomLevel = 1;
var _percentScrolled = 0, _xOffset = 0, _yOffset = 0, _imgRel = 2000/3600, _mx = 0, _my = 0;

//Get stage size
function resized(e){
  _sh = window.innerHeight;
  //Set document height in order for browser scroll to control zoom level
  _scrollAmount = _sh*1.5;
  document.body.style.height = _sh+_scrollAmount + "px";
  _sw = window.innerWidth;
  _imgDiv.style.width = _sw + "px";
  _mx = _sw*.5, _my = 0;//This is not needed, but makes the thumbnail on codepen look nice ;-)
}
window.addEventListener("resize", resized);
resized(null);


function scrolled(e){
  _windowScrollY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
   
  //Calculate percentage scrolled (zoom level)
  _percentScrolled = (_scrollAmount-_windowScrollY)/_scrollAmount;
  
}
window.addEventListener("scroll", scrolled);
scrolled(null);

function moved(e){
  _mx = e.clientX, _my = e.clientY;
}
document.body.addEventListener("mousemove", moved);

//Start render engine
TweenLite.ticker.addEventListener("tick", engine);
function engine(e){
  //Tween zoom level
  _zoomLevel += ((_percentScrolled+1)-_zoomLevel)*.1;
  
  //Calculate new offsets
  var _curImgH = (_percentScrolled+1)*(_sw/_imgRel);
  var _offY = -_my/_sh * (_curImgH-_sh);
  var _curImgW = (_percentScrolled+1)*_sw;
  var _offX = -(_mx/_sw-.5) * (_curImgW-_sw);
  //Tween offsets
  _yOffset += (_offY-_yOffset)*.1;
  _xOffset += (_offX-_xOffset)*.1;
  //Render
  TweenLite.set(_imgDiv, {x:_xOffset, y:_yOffset, scale:_zoomLevel, force3D:true, transformOrigin:"50% 0"});
}
              
            
!
999px

Console