Skewed One Page Scrolling Effect with jQuery and CSS3

Skewed One Page Scrolling Effect with jQuery and CSS3
File Size: 2.3 KB
Views Total: 6544
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A cool full window one page scroll webpage concept that makes use of jQuery and several CSS3 properties to create a fancy skewed page scrolling effect triggered by mousewheel events.

How to use it:

1. Add skewed pages to your website following the markup structure like this:

<div class="skw-pages">

  <div class="skw-page skw-page-1 active">
    <div class="skw-page__half skw-page__half--left">
      <div class="skw-page__skewed">
        <div class="skw-page__content"></div>
      </div>
    </div>
    <div class="skw-page__half skw-page__half--right">
      <div class="skw-page__skewed">
        <div class="skw-page__content">
          <h2 class="skw-page__heading">Page One</h2>
          <p class="skw-page__description">Desciption 1</p>
        </div>
      </div>
    </div>
  </div>

  <div class="skw-page skw-page-2">
    <div class="skw-page__half skw-page__half--left">
      <div class="skw-page__skewed">
        <div class="skw-page__content">
          <h2 class="skw-page__heading">Page Two</h2>
          <p class="skw-page__description">Description 2</p>
        </div>
      </div>
    </div>
    <div class="skw-page__half skw-page__half--right">
      <div class="skw-page__skewed">
        <div class="skw-page__content"></div>
      </div>
    </div>
  </div>

  ...
  
</div>

2. The core CSS / CSS3 rules.

.skw-pages {
  overflow: hidden;
  position: relative;
  height: 100vh;
}

.skw-page {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
}

.skw-page__half {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100vh;
  -webkit-transition: -webkit-transform 1s;
  transition: transform 1s;
}

.skw-page__half--left {
  left: 0;
  -webkit-transform: translate3d(-32.4vh, 100%, 0);
  transform: translate3d(-32.4vh, 100%, 0);
}

.skw-page__half--right {
  left: 50%;
  -webkit-transform: translate3d(32.4vh, -100%, 0);
  transform: translate3d(32.4vh, -100%, 0);
}

.skw-page.active .skw-page__half {
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

.skw-page__skewed {
  overflow: hidden;
  position: absolute;
  top: 0;
  width: 140%;
  height: 100%;
  -webkit-transform: skewX(-18deg);
  -ms-transform: skewX(-18deg);
  transform: skewX(-18deg);
  background: #000;
}

.skw-page__half--left .skw-page__skewed { left: -40%; }

.skw-page__half--right .skw-page__skewed { right: -40%; }

.skw-page__content {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-flex-flow: column wrap;
  -ms-flex-flow: column wrap;
  flex-flow: column wrap;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 0 30%;
  color: #fff;
  -webkit-transform: skewX(18deg);
  -ms-transform: skewX(18deg);
  transform: skewX(18deg);
  -webkit-transition: -webkit-transform 1s, opacity 1s;
  transition: transform 1s, opacity 1s;
  background-size: cover;
}

.skw-page__half--left .skw-page__content {
  padding-left: 30%;
  padding-right: 30%;
  -webkit-transform-origin: 100% 0;
  -ms-transform-origin: 100% 0;
  transform-origin: 100% 0;
}

.skw-page__half--right .skw-page__content {
  padding-left: 30%;
  padding-right: 30%;
  -webkit-transform-origin: 0 100%;
  -ms-transform-origin: 0 100%;
  transform-origin: 0 100%;
}

.skw-page.inactive .skw-page__content {
  opacity: 0.5;
  -webkit-transform: skewX(18deg) scale(0.95);
  -ms-transform: skewX(18deg) scale(0.95);
  transform: skewX(18deg) scale(0.95);
}

.skw-page__heading {
  margin-bottom: 15px;
  text-transform: uppercase;
  font-size: 25px;
  text-align: center;
}

.skw-page__description {
  font-size: 18px;
  text-align: center;
}

3. Add background images to the pages.

.skw-page-1 .skw-page__half--left .skw-page__content { background-image: url("1.jpg"); }

.skw-page-1 .skw-page__half--right .skw-page__content { background: #292929; }

.skw-page-2 .skw-page__half--left .skw-page__content { background: #292929; }

.skw-page-2 .skw-page__half--right .skw-page__content { background-image: url("2.jpg"); }

4. Load the latest version of jQuery library at the end of the webpage.

<script src="//code.jquery.com/jquery-2.1.4.min.js"></script> 

5. Active the skewed page scrolling effect.

$(document).ready(function() {

  var curPage = 1;
  var numOfPages = $(".skw-page").length;
  var animTime = 1000;
  var scrolling = false;
  var pgPrefix = ".skw-page-";

  function pagination() {
    scrolling = true;

    $(pgPrefix + curPage).removeClass("inactive").addClass("active");
    $(pgPrefix + (curPage - 1)).addClass("inactive");
    $(pgPrefix + (curPage + 1)).removeClass("active");

    setTimeout(function() {
      scrolling = false;
    }, animTime);
  };

  function navigateUp() {
    if (curPage === 1) return;
    curPage--;
    pagination();
  };

  function navigateDown() {
    if (curPage === numOfPages) return;
    curPage++;
    pagination();
  };

  $(document).on("mousewheel DOMMouseScroll", function(e) {
    if (scrolling) return;
    if (e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
      navigateUp();
    } else { 
      navigateDown();
    }
  });

  $(document).on("keydown", function(e) {
    if (scrolling) return;
    if (e.which === 38) {
      navigateUp();
    } else if (e.which === 40) {
      navigateDown();
    }
  });

});

This awesome jQuery plugin is developed by suez. For more Advanced Usages, please check the demo page or visit the official website.