title: Responsive parallax or layered vertical text effect
body: <p>I'm trying to reproduce the text effect as seen on <a href="http://www.balmain.com/en_eu/" rel="nofollow">http://www.balmain.com/en_eu/</a> - the text is vertically and horizontally centered in each div, but as you scroll down, the top position changes so that it has a parallax effect. As you scroll down, the text is replaced by the next div / image.</p>
  
  <p>On mobile, the text stops functioning in this 'parallax' way which is why I'm trying to test for mobile below in my JS. It sounds like it's a <a href="http://developer.telerik.com/featured/scroll-event-change-ios-8-big-deal/" rel="nofollow">very bad idea to attach handlers to the window scroll event</a>, so I'll have to look at that as well, but I need to get the effect working first.</p>
  
  <p>I'm really stuck on how to go about this as I looked through the code on the Balmain site, but I'm sure it could be done more simply than it is there so thought I'd ask here in case someone has done this before who could share their approach so I can learn?</p>
  
  <p><strong>Codepen</strong></p>
  
  <p><a href="http://codepen.io/anon/pen/gbJavv" rel="nofollow">http://codepen.io/anon/pen/gbJavv</a></p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;section class="slide slide-1"&gt;
      &lt;img src="http://placehold.it/1200x800" /&gt;
      &lt;a href="javascript:void(0);"&gt;
          &lt;span class="slide--generic-title clearfix"&gt;Enter The Shop&lt;/span&gt;
          &lt;span class="slide--custom-title"&gt;One piece tees&lt;/span&gt;
      &lt;/a&gt;
  &lt;/section&gt;
  
  &lt;section class="slide slide-2"&gt;
      &lt;img src="http://placehold.it/1200x800" /&gt;
      &lt;a href="javascript:void(0);"&gt;
          &lt;span class="slide--generic-title clearfix"&gt;Enter The Shop&lt;/span&gt;
          &lt;span class="slide--custom-title"&gt;Company&lt;/span&gt;
      &lt;/a&gt;
  &lt;/section&gt;
  
  &lt;section class="slide slide-3"&gt;
      &lt;img src="http://placehold.it/1200x800" /&gt;
      &lt;a href="javascript:void(0);"&gt;
          &lt;span class="slide--generic-title clearfix"&gt;Enter The Shop&lt;/span&gt;
          &lt;span class="slide--custom-title"&gt;Values&lt;/span&gt;
      &lt;/a&gt;
  &lt;/section&gt;
  
  &lt;section class="slide slide-4"&gt;
      &lt;img src="http://placehold.it/1200x800" /&gt;
      &lt;a href="javascript:void(0);"&gt;
          &lt;span class="slide--generic-title clearfix"&gt;Enter The Shop&lt;/span&gt;
          &lt;span class="slide--custom-title"&gt;Shoes&lt;/span&gt;
      &lt;/a&gt;
  &lt;/section&gt;
  
  &lt;section class="slide slide-5"&gt;
      &lt;img src="http://placehold.it/1200x800" /&gt;
      &lt;a href="javascript:void(0);"&gt;
          &lt;span class="slide--generic-title clearfix"&gt;Enter The Shop&lt;/span&gt;
          &lt;span class="slide--custom-title"&gt;T-shirts&lt;/span&gt;
      &lt;/a&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p><strong>CSS</strong></p>
  
  <pre><code>/* SECTIONS LAYOUT */
  section {
      position: relative;
      text-align: center;
      overflow: hidden;
  }
  section img {
      width:100%;
      height:auto;
  }
  section a {
      position: absolute;
      left:50%;
      top:50%;
      display:block;
      width:400px;
      margin-left:-200px;
      font-size: 2em;
      color:#000;
  }
  
  /* GENERAL STYLING */
  body {
      padding:0;
      margin:0;
      font-family:arial, helvetica, verdana, sans-serif;
      font-size:0.9em;
      color:#333;
  }
  a {
      text-decoration: none;
  }
  img {
      display:block;
  }
  .clearfix:after {
      content:".";
      display:block;
      clear:both;
      visibility:hidden;
      line-height:0;
      height:0
  }
  section {
      border-bottom:1px solid #fff;
  }
  </code></pre>
  
  <p><strong>JQUERY</strong></p>
  
  <pre><code>// Check for mobile (not perfect, but a good technique using Modernizr)
  // Source: http://stackoverflow.com/a/17326467/621098
  var deviceAgent = navigator.userAgent.toLowerCase();
  var isTouchDevice = Modernizr.touch || 
      (deviceAgent.match(/(iphone|ipod|ipad)/) ||
       deviceAgent.match(/(android)/)  || 
       deviceAgent.match(/(iemobile)/) || 
       deviceAgent.match(/iphone/i) || 
       deviceAgent.match(/ipad/i) || 
       deviceAgent.match(/ipod/i) || 
       deviceAgent.match(/blackberry/i) || 
       deviceAgent.match(/webos/) || 
       deviceAgent.match(/bada/i)
      );
  
  // Affect non-mobile devices on scroll
  if (!isTouchDevice) {
  
      // On scroll
      $(window).scroll(function() {
          // Do stuff
      });
  
      // On resize
      $(window).resize(function() {
              // Do stuff
      });
  
  } else {
      // Show the text centered in the section only
  }
  </code></pre>