css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

              <canvas id="wall"></canvas>
<div id="wallScrollerWrap">
  <div id="wallScroller"></div>
              body {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
#wallScrollerWrap {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
#wallScroller {
  width: 5000px;
  height: 100px;
              // --------------------------
// Inital Vars / Wall
// --------------------------

// Initialize IScoll for wall
var wallScroll = new IScroll('#wallScrollerWrap', {
  probeType: 3, // 1-3, 3 being the most accurate option (required for certain features) but also the most resource demanding option
  zoom: false,
  zoomMax: 1,
  scrollX: true,
  scrollY: false,
  mouseWheel: true,

// canvas
var c = $('#wall');
// get canvas context so we can draw on it later
var ctx = c[0].getContext('2d');
// image(s) we will be drawing...
var wall_image_urls = [
var image_ready = false;

function resize_canvas() {
  var winWidth = $(window).outerWidth(true);
  var winHeight = $(window).outerHeight(true);
  c[0].width = winWidth;
  c[0].height = winHeight;
  // try playing around with these values to see how it affects the canvas
  // c[0].width = 400;
  // c[0].height = 200;
  // c.css({
  //   width: 600+'px',
  //   height: 200+'px'
  // });
// immediately resize canvas  
// resize canvas again if window is resized
var debounce_resize;
$(window).on('resize orientationchange', function(){
  // The timeout acts as a debounce as well has a timeout for mobile devices as they take about 2-300 ms to complete an orientationchange
  debounce_resize = setTimeout(function(){
    // we have to now redraw the canvas or what is on it may be stretched
    if( image_ready ) { // lets make sure the images have been loaded
  }, 300);

// --------------------------
// load a wall image
// --------------------------

var wall_image_data;
wall_image = new Image();
// make sure you add the onload event before the src or the image may load be fire this func is defined
wall_image.onload = function(){
  imgWidth = this.width;
  imgHeight = this.height; 
  // store image obj in array
  wall_image_data = {
    img: this, // image obj to be drawn by canvas
    imgWidth: imgWidth,
    imgHeight: imgHeight
  image_ready = true;
  // added scroll event
  wallScroll.on('scroll', function(){
  // draw the image
wall_image.src = wall_image_urls[0];

// function draw the image
function draw(x) {
  // get the image/canvas ratio
  var wallHeight = c.height();
  var img_height_ratio = wallHeight / wall_image_data.imgHeight;
  // clear canvas or it will show what you last drew
  ctx.clearRect(0, 0, c[0].width, c[0].height);
  // draw image with new position
  ctx.drawImage(wall_image_data.img, x, 0, wall_image_data.imgWidth*img_height_ratio,wall_image_data.imgHeight*img_height_ratio);
🕑 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.
Loading ..................