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

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

              
                 <section class="container container-0">

    <canvas class="center canvas" width="300" height="300"></canvas>
    <div class="next">&lsaquo;</div>

  </section>

  <section class="container container-1">

    <div class="prev">&rsaquo;</div>
    <canvas class="center canvas" width="300" height="300"></canvas>
    <div class="next">&lsaquo;</div>

  </section>

  <section class="container container-2">

    <div class="prev">&rsaquo;</div>
    <canvas class="center canvas" width="300" height="300"></canvas>
    <div class="next">&lsaquo;</div>

  </section>

  <section class="container container-3">

    <div class="prev">&rsaquo;</div>
    <canvas class="center canvas" width="300" height="300"></canvas>
    <div class="next">&lsaquo;</div>

  </section>

  <section class="container container-4">

    <div class="prev">&rsaquo;</div>
    <canvas class="center canvas" width="300" height="300"></canvas>
    <div class="next">&lsaquo;</div>

  </section>

  <section class="container container-5">

    <div class="prev">&rsaquo;</div>
    <canvas class="center canvas" width="300" height="300"></canvas>

  </section>

              
            
!

CSS

              
                html, body{
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body{
  background: #eee;
  overflow-x: hidden;
}

.container{
  width: 100%;
  height: 100%;
  min-height: 500px;
  overflow: hidden;
  position: relative;
}

.next, .prev{
  background: #181818;
  width: 50px;
  height: 50px;
  cursor: pointer;
  color: #181818;
  line-height: 42px;
  font-size: 2em;
  text-align: center;
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0) rotate(-90deg);
  z-index: 4;
}

.next{
  bottom: 0;
}

h1{
  color: #eee;
}

.center{
  position: absolute;
  margin: auto;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
}

.rect{
  width: 50px;
  height: 50px;
  background: #eee;
  z-index: 0;
  background: #eee;
}

.rect, canvas, .next, .prev{
  will-change: transform;
}

canvas{
  z-index: 1;
}
              
            
!

JS

              
                /*
click the canvas animation to perfect centering

check the javascript on github https://github.com/EduardoLopes/parallax-scroll-experiment

*/


/*
  update: 27.09.209 10:33 AM
  
  I'm pasting the tween.js code here, because RawGit (https://rawgit.com/) has reached the end of its useful life and the experiment was broken. this is a quick fix

The arrow navigation seems like it's not working on chrome latest  

*/

var _Group=function(){this._tweens={},this._tweensAddedDuringUpdate={}};_Group.prototype={getAll:function(){return Object.keys(this._tweens).map(function(t){return this._tweens[t]}.bind(this))},removeAll:function(){this._tweens={}},add:function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},remove:function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},update:function(t,n){var e=Object.keys(this._tweens);if(0===e.length)return!1;for(t=void 0!==t?t:TWEEN.now();e.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<e.length;i++){var s=this._tweens[e[i]];s&&!1===s.update(t)&&(s._isPlaying=!1,n||delete this._tweens[e[i]])}e=Object.keys(this._tweensAddedDuringUpdate)}return!0}};var TWEEN=new _Group;TWEEN.Group=_Group,TWEEN._nextId=0,TWEEN.nextId=function(){return TWEEN._nextId++},"undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?TWEEN.now=function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?TWEEN.now=self.performance.now.bind(self.performance):void 0!==Date.now?TWEEN.now=Date.now:TWEEN.now=function(){return(new Date).getTime()},TWEEN.Tween=function(t,n){this._isPaused=!1,this._pauseStart=null,this._object=t,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._repeatDelayTime=void 0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=TWEEN.Easing.Linear.None,this._interpolationFunction=TWEEN.Interpolation.Linear,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onRepeatCallback=null,this._onCompleteCallback=null,this._onStopCallback=null,this._group=n||TWEEN,this._id=TWEEN.nextId()},TWEEN.Tween.prototype={getId:function(){return this._id},isPlaying:function(){return this._isPlaying},isPaused:function(){return this._isPaused},to:function(t,n){return this._valuesEnd=Object.create(t),void 0!==n&&(this._duration=n),this},duration:function(t){return this._duration=t,this},start:function(t){for(var n in this._group.add(this),this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._startTime=void 0!==t?"string"==typeof t?TWEEN.now()+parseFloat(t):t:TWEEN.now(),this._startTime+=this._delayTime,this._valuesEnd){if(this._valuesEnd[n]instanceof Array){if(0===this._valuesEnd[n].length)continue;this._valuesEnd[n]=[this._object[n]].concat(this._valuesEnd[n])}void 0!==this._object[n]&&(void 0===this._valuesStart[n]&&(this._valuesStart[n]=this._object[n]),this._valuesStart[n]instanceof Array==!1&&(this._valuesStart[n]*=1),this._valuesStartRepeat[n]=this._valuesStart[n]||0)}return this},stop:function(){return this._isPlaying?(this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,null!==this._onStopCallback&&this._onStopCallback(this._object),this.stopChainedTweens(),this):this},end:function(){return this.update(1/0),this},pause:function(t){return this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=void 0===t?TWEEN.now():t,this._group.remove(this),this)},resume:function(t){return this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=(void 0===t?TWEEN.now():t)-this._pauseStart,this._pauseStart=0,this._group.add(this),this):this},stopChainedTweens:function(){for(var t=0,n=this._chainedTweens.length;t<n;t++)this._chainedTweens[t].stop()},group:function(t){return this._group=t,this},delay:function(t){return this._delayTime=t,this},repeat:function(t){return this._repeat=t,this},repeatDelay:function(t){return this._repeatDelayTime=t,this},yoyo:function(t){return this._yoyo=t,this},easing:function(t){return this._easingFunction=t,this},interpolation:function(t){return this._interpolationFunction=t,this},chain:function(){return this._chainedTweens=arguments,this},onStart:function(t){return this._onStartCallback=t,this},onUpdate:function(t){return this._onUpdateCallback=t,this},onRepeat:function(t){return this._onRepeatCallback=t,this},onComplete:function(t){return this._onCompleteCallback=t,this},onStop:function(t){return this._onStopCallback=t,this},update:function(t){var n,e,i;if(t<this._startTime)return!0;for(n in!1===this._onStartCallbackFired&&(null!==this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),e=(t-this._startTime)/this._duration,e=0===this._duration||e>1?1:e,i=this._easingFunction(e),this._valuesEnd)if(void 0!==this._valuesStart[n]){var s=this._valuesStart[n]||0,r=this._valuesEnd[n];r instanceof Array?this._object[n]=this._interpolationFunction(r,i):("string"==typeof r&&(r="+"===r.charAt(0)||"-"===r.charAt(0)?s+parseFloat(r):parseFloat(r)),"number"==typeof r&&(this._object[n]=s+(r-s)*i))}if(null!==this._onUpdateCallback&&this._onUpdateCallback(this._object,e),1===e){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat){if("string"==typeof this._valuesEnd[n]&&(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo){var a=this._valuesStartRepeat[n];this._valuesStartRepeat[n]=this._valuesEnd[n],this._valuesEnd[n]=a}this._valuesStart[n]=this._valuesStartRepeat[n]}return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,null!==this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}null!==this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,u=this._chainedTweens.length;o<u;o++)this._chainedTweens[o].start(this._startTime+this._duration);return!1}return!0}},TWEEN.Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var n=1.70158;return t*t*((n+1)*t-n)},Out:function(t){var n=1.70158;return--t*t*((n+1)*t+n)+1},InOut:function(t){var n=2.5949095;return(t*=2)<1?t*t*((n+1)*t-n)*.5:.5*((t-=2)*t*((n+1)*t+n)+2)}},Bounce:{In:function(t){return 1-TWEEN.Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*TWEEN.Easing.Bounce.In(2*t):.5*TWEEN.Easing.Bounce.Out(2*t-1)+.5}}},TWEEN.Interpolation={Linear:function(t,n){var e=t.length-1,i=e*n,s=Math.floor(i),r=TWEEN.Interpolation.Utils.Linear;return n<0?r(t[0],t[1],i):n>1?r(t[e],t[e-1],e-i):r(t[s],t[s+1>e?e:s+1],i-s)},Bezier:function(t,n){for(var e=0,i=t.length-1,s=Math.pow,r=TWEEN.Interpolation.Utils.Bernstein,a=0;a<=i;a++)e+=s(1-n,i-a)*s(n,a)*t[a]*r(i,a);return e},CatmullRom:function(t,n){var e=t.length-1,i=e*n,s=Math.floor(i),r=TWEEN.Interpolation.Utils.CatmullRom;return t[0]===t[e]?(n<0&&(s=Math.floor(i=e*(1+n))),r(t[(s-1+e)%e],t[s],t[(s+1)%e],t[(s+2)%e],i-s)):n<0?t[0]-(r(t[0],t[0],t[1],t[1],-i)-t[0]):n>1?t[e]-(r(t[e],t[e],t[e-1],t[e-1],i-e)-t[e]):r(t[s?s-1:0],t[s],t[e<s+1?e:s+1],t[e<s+2?e:s+2],i-s)},Utils:{Linear:function(t,n,e){return(n-t)*e+t},Bernstein:function(t,n){var e=TWEEN.Interpolation.Utils.Factorial;return e(t)/e(n)/e(t-n)},Factorial:function(){var t=[1];return function(n){var e=1;if(t[n])return t[n];for(var i=n;i>1;i--)e*=i;return t[n]=e,e}}(),CatmullRom:function(t,n,e,i,s){var r=.5*(e-t),a=.5*(i-n),o=s*s;return(2*n-2*e+r+a)*(s*o)+(-3*n+3*e-2*r-a)*o+r*s+n}}};

!function t(i,n,e){function o(r,s){if(!n[r]){if(!i[r]){var h="function"==typeof require&&require;if(!s&&h)return h(r,!0);if(a)return a(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[r]={exports:{}};i[r][0].call(l.exports,function(t){var n=i[r][1][t];return o(n?n:t)},l,l.exports,t,i,n,e)}return n[r].exports}for(var a="function"==typeof require&&require,r=0;r<e.length;r++)o(e[r]);return o}({1:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function o(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i&&(t.__proto__=i)}function a(t,i,n,e){return Math.sqrt(Math.pow(t-n,2)+Math.pow(i-e,2))}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),s=function(t,i,n){for(var e=!0;e;){var o=t,a=i,r=n;s=c=h=void 0,e=!1,null===o&&(o=Function.prototype);var s=Object.getOwnPropertyDescriptor(o,a);if(void 0!==s){if("value"in s)return s.value;var h=s.get;return void 0===h?void 0:h.call(r)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;t=c,i=a,n=r,e=!0}},h=t("./animation"),c=t("./rect"),l=4,u=40,f=(new Random(Random.engines.mt19937().autoSeed()),function(t){function i(t,n){e(this,i),s(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,0,0,15),this.index=t,this.animation=n,this.id=this.index%4,this.angle=Math.floor(this.index/4)*(2*Math.PI/(u/4))}return o(i,t),r(i,[{key:"update_0",value:function(){this.x=Math.max(150,Math.min(300-this.size,this.x)),this.y=Math.max(150,Math.min(300-this.size,this.y)),this.angle+=.01}},{key:"update_1",value:function(){this.x=Math.max(0,Math.min(150-this.size,this.x)),this.y=Math.max(0,Math.min(150-this.size,this.y)),this.angle+=.011}},{key:"update_2",value:function(){this.x=Math.max(150,Math.min(300-this.size,this.x)),this.y=Math.max(0,Math.min(150-this.size,this.y)),this.angle+=.012}},{key:"update_3",value:function(){this.x=Math.max(0,Math.min(150-this.size,this.x)),this.y=Math.max(150,Math.min(300-this.size,this.y)),this.angle+=.013}},{key:"update",value:function(){this.x=this.animation.center.x+300*Math.cos(this.angle),this.y=this.animation.center.y+300*Math.sin(this.angle),this["update_"+this.id](),this.size=15*(a(this.x,this.y,this.animation.center.x,this.animation.center.y)/300)+2}},{key:"draw",value:function(){this.animation.ctx.fillStyle=this.animation.color,this.animation.ctx.fillRect(this.x,this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal,this.size,this.size)}}]),i}(c.Rect)),p=function(t){function i(){e(this,i),s(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,l,f,u)}return o(i,t),i}(h.Animation);n.AnimationFive=p},{"./animation":7,"./rect":12}],2:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function o(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i&&(t.__proto__=i)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),r=function(t,i,n){for(var e=!0;e;){var o=t,a=i,r=n;s=c=h=void 0,e=!1,null===o&&(o=Function.prototype);var s=Object.getOwnPropertyDescriptor(o,a);if(void 0!==s){if("value"in s)return s.value;var h=s.get;return void 0===h?void 0:h.call(r)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;t=c,i=a,n=r,e=!0}},s=t("./animation"),h=t("./rect"),c=3,l=40,u=function(t){function i(t,n){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,0,0,15),this.index=t,this.animation=n,this.angle=this.index*(2*Math.PI/l)}return o(i,t),a(i,[{key:"update",value:function(){this.x=this.animation.center.x+300*Math.cos(this.angle),this.y=this.animation.center.y+300*Math.sin(this.angle),this.index%5==0?(this.x=Math.max(0,Math.min(300-this.size,this.x)),this.y=Math.max(0,Math.min(300-this.size,this.y)),this.angle+=.01):(this.x=Math.max(30,Math.min(270-this.size,this.x)),this.y=Math.max(30,Math.min(270-this.size,this.y)),this.angle-=.005)}},{key:"draw",value:function(){this.animation.ctx.fillStyle=this.animation.color,this.animation.ctx.fillRect(this.x,this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal,this.size,this.size)}}]),i}(h.Rect),f=function(t){function i(){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,c,u,l)}return o(i,t),i}(s.Animation);n.AnimationFour=f},{"./animation":7,"./rect":12}],3:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function o(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i&&(t.__proto__=i)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),r=function(t,i,n){for(var e=!0;e;){var o=t,a=i,r=n;s=c=h=void 0,e=!1,null===o&&(o=Function.prototype);var s=Object.getOwnPropertyDescriptor(o,a);if(void 0!==s){if("value"in s)return s.value;var h=s.get;return void 0===h?void 0:h.call(r)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;t=c,i=a,n=r,e=!0}},s=t("./animation"),h=t("./rect"),c=0,l=60,u=function(t){function i(t,n){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,0,0,3.75*(t%4+1)),this.index=t,this.animation=n,this.angle=this.index*(2*Math.PI/l)}return o(i,t),a(i,[{key:"update",value:function(){this.x=this.animation.center.x+300*Math.cos(this.angle),this.y=this.animation.center.y+300*Math.sin(this.angle),this.index%4==0?(this.x=Math.max(0,Math.min(300-this.size,this.x)),this.y=Math.max(0,Math.min(300-this.size,this.y)),this.angle+=.01):this.index%4==1?(this.x=Math.max(15,Math.min(285-this.size,this.x)),this.y=Math.max(15,Math.min(285-this.size,this.y)),this.angle+=.011):this.index%4==2?(this.x=Math.max(30,Math.min(270-this.size,this.x)),this.y=Math.max(30,Math.min(270-this.size,this.y)),this.angle+=.012):this.index%4==3&&(this.x=Math.max(45,Math.min(255-this.size,this.x)),this.y=Math.max(45,Math.min(255-this.size,this.y)),this.angle+=.013)}},{key:"draw",value:function(){this.animation.ctx.fillStyle=this.animation.color,this.animation.ctx.fillRect(this.x,this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal,this.size,this.size)}}]),i}(h.Rect),f=function(t){function i(){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,c,u,l)}return o(i,t),i}(s.Animation);n.AnimationOne=f},{"./animation":7,"./rect":12}],4:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function o(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i&&(t.__proto__=i)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),r=function(t,i,n){for(var e=!0;e;){var o=t,a=i,r=n;s=c=h=void 0,e=!1,null===o&&(o=Function.prototype);var s=Object.getOwnPropertyDescriptor(o,a);if(void 0!==s){if("value"in s)return s.value;var h=s.get;return void 0===h?void 0:h.call(r)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;t=c,i=a,n=r,e=!0}},s=t("./animation"),h=t("./rect"),c=5,l=20,u=function(t){function i(t,n){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,0,0,15),this.index=t,this.animation=n,this.angle=this.index*(2*Math.PI/l)}return o(i,t),a(i,[{key:"update",value:function(){this.x=this.animation.center.x+300*Math.cos(this.angle),this.y=this.animation.center.y+300*Math.sin(this.angle),this.x=Math.max(0,Math.min(300-this.size,this.x)),this.y=Math.max(0,Math.min(300-this.size,this.y)),this.index%2==0?this.angle+=.01:this.angle-=.01}},{key:"draw",value:function(){var t=this.animation.objects[this.index+5];this.animation.ctx.fillStyle=this.animation.color,this.animation.ctx.strokeStyle=this.animation.color,this.animation.ctx.fillRect(this.x,this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal,this.size,this.size),"undefined"!=typeof t&&(this.animation.ctx.beginPath(),this.animation.ctx.lineWidth=15,this.animation.ctx.moveTo(this.x+this.size/2,this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal+this.size/2),this.animation.ctx.lineTo(t.x+t.size/2,t.y+this.animation.scrollPosition/100*t.parallaxOffsetHorizontal+t.size/2),this.animation.ctx.closePath(),this.animation.ctx.stroke())}}]),i}(h.Rect),f=function(t){function i(){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,c,u,l)}return o(i,t),i}(s.Animation);n.AnimationSix=f},{"./animation":7,"./rect":12}],5:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function o(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i&&(t.__proto__=i)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),r=function(t,i,n){for(var e=!0;e;){var o=t,a=i,r=n;s=c=h=void 0,e=!1,null===o&&(o=Function.prototype);var s=Object.getOwnPropertyDescriptor(o,a);if(void 0!==s){if("value"in s)return s.value;var h=s.get;return void 0===h?void 0:h.call(r)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;t=c,i=a,n=r,e=!0}},s=t("./animation"),h=t("./rect"),c=2,l=20,u=function(t){function i(t,n){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,0,0,t*(215/l)),this.index=t,this.animation=n,this.angle=this.index*(2*Math.PI/l),this.x=this.animation.$canvas.width/2-this.size/2,this.y=this.animation.$canvas.height/2-this.size/2}return o(i,t),a(i,[{key:"update",value:function(){this.index%2==0?this.angle+=.01:this.angle-=.01}},{key:"draw",value:function(){var t=this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal;this.animation.ctx.save(),this.animation.ctx.strokeStyle=this.animation.color,this.animation.ctx.fillStyle=this.animation.color,this.animation.ctx.lineWidth=4,this.animation.ctx.translate(this.x+this.size/2,t+this.size/2),this.animation.ctx.rotate(this.angle),this.animation.ctx.translate(-(this.x+this.size/2),-(t+this.size/2)),this.animation.ctx.beginPath(),this.animation.ctx.rect(this.x,t,this.size,this.size),this.animation.ctx.closePath(),this.animation.ctx.stroke(),this.animation.ctx.globalCompositeOperation="xor",this.animation.ctx.fillRect(this.x,t,this.size,this.size),this.animation.ctx.restore()}}]),i}(h.Rect),f=function(t){function i(){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,c,u,l)}return o(i,t),i}(s.Animation);n.AnimationThree=f},{"./animation":7,"./rect":12}],6:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function o(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i&&(t.__proto__=i)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),r=function(t,i,n){for(var e=!0;e;){var o=t,a=i,r=n;s=c=h=void 0,e=!1,null===o&&(o=Function.prototype);var s=Object.getOwnPropertyDescriptor(o,a);if(void 0!==s){if("value"in s)return s.value;var h=s.get;return void 0===h?void 0:h.call(r)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;t=c,i=a,n=r,e=!0}},s=t("./animation"),h=t("./rect"),c=1,l=20,u=function(t){function i(t,n){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,0,0,15),this.index=t,this.animation=n,this.angle=this.index*(2*Math.PI/l)}return o(i,t),a(i,[{key:"update",value:function(){this.x=this.animation.center.x+300*Math.cos(this.angle),this.y=this.animation.center.y+300*Math.sin(this.angle),this.index%2==0?(this.x=Math.max(0,Math.min(300-this.size,this.x)),this.y=Math.max(0,Math.min(300-this.size,this.y)),this.angle+=.01):(this.x=Math.max(75,Math.min(225-this.size,this.x)),this.y=Math.max(75,Math.min(225-this.size,this.y)),this.angle-=.01)}},{key:"draw",value:function(){this.animation.ctx.fillStyle=this.animation.color,this.index%2==0?this.animation.ctx.fillRect(this.x,this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal,this.size,this.size):this.animation.ctx.fillRect(this.x+this.size/4,this.y+this.animation.scrollPosition/100*this.parallaxOffsetHorizontal+this.size/4,this.size,this.size)}}]),i}(h.Rect),f=function(t){function i(){e(this,i),r(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,c,u,l)}return o(i,t),i}(s.Animation);n.AnimationTwo=f},{"./animation":7,"./rect":12}],7:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),a=t("./colors"),r=function(){function t(i,n,o){e(this,t),this.objects=[],this.onScreen=!1,this.id=i,this.color="hsl("+a.COLORS[this.id].h+", "+(a.COLORS[this.id].s+30)+"%, "+(a.COLORS[this.id].l+20)+"%)",this.$canvas=$(".container-"+i).children(".canvas")[0],this.ctx=this.$canvas.getContext("2d"),this.scrollPosition=0,this.center={x:this.$canvas.width/2,y:this.$canvas.height/2};for(var r=0;o>r;r++)this.objects[r]=new n(r,this)}return o(t,[{key:"update",value:function(){for(var t=0;t<this.objects.length;t++)this.objects[t].update()}},{key:"draw",value:function(){this.ctx.clearRect(0,0,this.$canvas.width,this.$canvas.height);for(var t=0;t<this.objects.length;t++)this.objects[t].draw()}}]),t}();n.Animation=r},{"./colors":8}],8:[function(t,i,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var e=t("./hsl"),o=[new e.HSL(351,51,51),new e.HSL(31,91,55),new e.HSL(58,90,55),new e.HSL(111,41,48),new e.HSL(212,71,40),new e.HSL(256,41,44)];n.COLORS=o},{"./hsl":9}],9:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function t(t,i){for(var n=0;n<i.length;n++){var e=i[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}return function(i,n,e){return n&&t(i.prototype,n),e&&t(i,e),i}}(),a=function(){function t(i,n,o){e(this,t),this.h=i,this.s=n,this.l=o}return o(t,[{key:"toString",value:function(){return"hsl("+this.h+","+this.s+"%,"+this.l+"%)"}}]),t}();n.HSL=a},{}],10:[function(t,i,n){"use strict";function e(t){var i=$("<div></div>"),n=v.random.integer(50,150),e=v.random.integer(-b,b),o=v.random.integer(-g,g),a=v.random.integer(-200,200),r=v.random.integer(-200,200);return i.addClass("center rect"),i.data("pixels-to-travel-vertical",a),i.data("pixels-to-travel-horizontal",r),i.css({width:n,height:n,top:o,left:e,background:"hsl("+h.COLORS[t].h+","+(h.COLORS[t].s+20)+"%,"+(h.COLORS[t].l+10)+"%)",opacity:.5}),i}function o(t){x.stop(),x.to({scrollTo:t}),x.start()}function a(){var t=void 0,i=void 0;h.COLORS.forEach(function(t,i){$(d[i]).css("background",h.COLORS[i].toString())}),d.each(function(n,o){t=$(o),i=t.children(".canvas"),t.children(".prev, .next").css({background:"hsl("+h.COLORS[n].h+","+(h.COLORS[n].s+20)+"%,"+(h.COLORS[n].l+15)+"%)"}),i.css({border:"hsl("+h.COLORS[n].h+","+(h.COLORS[n].s+20)+"%,"+(h.COLORS[n].l+10)+"%) solid 10px",background:"hsl("+h.COLORS[n].h+","+(h.COLORS[n].s-5)+"%,"+(h.COLORS[n].l-15)+"%)"});for(var a=0;10>a;a++)t.append(e(n))})}function r(){var t=y.scrollTop(),i=void 0,n=void 0,e=void 0,o=void 0,a=void 0,r=void 0,s=void 0,h=void 0,c=void 0,l=void 0,u=void 0,f=void 0;g=y.height(),b=y.width(),d.each(function(p,m){n=$(m),e=n.offset(),o=n.children(".canvas"),a=n.height(),r=Math.max(0,Math.min(100,(e.top+a-t)/(g+a)*100)),s=r-50,h=s/50*100,c=h/100,l=n.children(".prev"),u=n.children(".next"),l.css("transform","translate(-50%, "+50*-c+"px) rotate(-90deg)"),u.css("transform","translate(-50%, "+50*-c+"px) rotate(-90deg)"),t+g>e.top&&e.top+n.height()>t&&(i=n.children(".rect"),o.css("transform","translate(0, "+400*c+"px)"),i.each(function(i,n){f=$(n),t+g>f.offset().top&&f.offset().top+f.height()>t&&f.css("transform","translate("+c*parseInt(f.data("pixels-to-travel-horizontal"))+"px, "+c*parseInt(f.data("pixels-to-travel-vertical"))+"px)")})),t+g>o.offset().top&&o.offset().top+o.height()>t?(O[p].onScreen=!0,O[p].scrollPosition=h):O[p].onScreen=!1})}function s(){for(var t=0;t<O.length;t++)O[t].onScreen&&(O[t].update(),O[t].draw());TWEEN.update(),requestAnimationFrame(s)}var h=t("./colors"),c=t("./animation-one"),l=t("./animation-two"),u=t("./animation-three"),f=t("./animation-four"),p=t("./animation-five"),m=t("./animation-six"),v=t("./random"),y=$(window),d=($(document),$(".container")),x=new TWEEN.Tween(o).to({scrollTo:0},1e3).easing(TWEEN.Easing.Quartic.InOut).onUpdate(function(){y.scrollTop(this.scrollTo)}).onStart(function(){this.scrollTo=y.scrollTop()}),O=[new c.AnimationOne,new l.AnimationTwo,new u.AnimationThree,new f.AnimationFour,new p.AnimationFive,new m.AnimationSix],g=y.height(),b=y.width();$(".next").on("click",function(){var t=$(this);o(t.parent().next().offset().top)}),$(".prev").on("click",function(){var t=$(this);o(t.parent().prev().offset().top)}),$(".canvas").on("click",function(){var t=$(this);o(t.parent().offset().top)}),y.on("mousewheel",function(){x.stop()}),y.on("resize scroll load",r),requestAnimationFrame(s),a()},{"./animation-five":1,"./animation-four":2,"./animation-one":3,"./animation-six":4,"./animation-three":5,"./animation-two":6,"./colors":8,"./random":11}],11:[function(t,i,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var e=new Random(Random.engines.mt19937().autoSeed());n.random=e},{}],12:[function(t,i,n){"use strict";function e(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=t("./random"),a=function r(t,i,n){e(this,r),this.x=t,this.y=i,this.size=n,this.angle=0,this.parallaxOffsetHorizontal=o.random.integer(200,600),this.parallaxOffsetVertical=o.random.integer(200,600)};n.Rect=a},{"./random":11}]},{},[10]);
//# sourceMappingURL=bundle.js.map
              
            
!
999px

Console