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.

            
              <div class="forward_wrapper">
    <div class="forward_scroll">
        <div class="forward_phone">
            <div class="forward_mockup_container">
                <img src="https://i.imgur.com/am6Gd9x.png" alt="" class="forward_mockup">
            </div>
            <div class="forward_slides_container">
                <span class="fake_slide active" id="slide0"></span>
                <div class="forward_phoneslide first_slide" id="slide1">
                    <img src="https://i.imgur.com/XEzcTxk.jpg" alt="" class="slide" />
                </div>
                <div class="forward_phoneslide" id="slide2">
                    <img src="https://i.imgur.com/wJmgAa8.jpg" alt="" class="slide" />
                </div>
                <div class="forward_phoneslide" id="slide3">
                    <img src="https://i.imgur.com/M1PzqDh.jpg" alt="" class="slide" />
                </div>
                <div class="forward_phoneslide" id="slide4">
                    <img src="https://i.imgur.com/yJO5qWA.jpg" alt="" class="slide" />
                </div>
                <span class="fake_slide_footer active" id="slide5"></span>
            </div>
        </div>
        <div class="forward_content_wrapper forward_header">
            <div class="forward_content header_content" id="content0">
                <div class="header_image">
                    <div class="header_container">
                        <div class="forward_headline">
                            <h2>Please view in full page</h2>
                            <p>Custom responsive one page scroll - Made from scratch with jQuery - Can be tricky to customize</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="forward_content_container">
            <ul class="forward_nav"></ul>
            <div class="forward_content_wrapper alternative_bg first">
                <div class="forward_content normal_content" id="content1">
                    <h3 class="title">Dependencies</h3>
                    <p class="description">Sass, jQuery, Velocity.js, jQuery TouchSwipe</p>
                    <div class="forward_scroll_arrow">
                        <img src="https://i.imgur.com/K4IzEqw.png" alt="" width="100%" class="arrow" id="arrow1">
                    </div>
                </div>
            </div>
            <div class="forward_content_wrapper alternative_bg second">
                <div class="forward_content normal_content" id="content2">
                    <h3 class="title">Features</h3>
                    <p class="description">Fully responsive, fully customizable (although pretty hard), scroll up/down, swipe up/down, keyboard arrows up/down (apparently not on Codepen lol), navigation bar, navigation arrows on each slide; You can also add more slides (will have tutorial for this soon)</p>
                    <div class="forward_scroll_arrow">
                        <img src="https://i.imgur.com/K4IzEqw.png" alt="" width="100%" class="arrow" id="arrow2">
                    </div>
                </div>
            </div>
            <div class="forward_content_wrapper alternative_bg third">
                <div class="forward_content normal_content" id="content3">
                    <h3 class="title">Two way scroll</h3>
                    <p class="description">You can adjust this page to have one content scroll up and another down (will have example of this soon)</p>
                    <div class="forward_scroll_arrow">
                        <img src="https://i.imgur.com/K4IzEqw.png" alt="" width="100%" class="arrow" id="arrow3">
                    </div>
                </div>
            </div>
            <div class="forward_content_wrapper alternative_bg fourth">
                <div class="forward_content normal_content" id="content4">
                    <h3 class="title">To do</h3>
                    <p class="description">Sticky top navigation menu;</p>
                    <div class="forward_scroll_arrow">
                        <img src="https://i.imgur.com/K4IzEqw.png" alt="" width="100%" class="arrow" id="arrow4">
                    </div>
                </div>
            </div>
            <div class="forward_content_wrapper forward_footer">
                <div class="forward_content footer_content" id="content5">
                    <h3 class="title">Feel free to use it in your projects if you like it.</h3>
                    <p class="description">Good luck!</p>
                </div>
            </div>
        </div>
    </div>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,300italic,400italic,600italic,700italic&subset=latin,latin-ext,greek);

* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html, body {
    overflow: hidden;
    -webkit-overflow-scrolling: auto;
    margin: 0
}

.forward_wrapper {
    width: 100%;
    background-color: #ffffff;
    color: #ffffff;
    margin: 0 auto;
    position: relative;

    .forward_nav {
        position: absolute;
        top: 0;
        right: 10px;
        display: inline-block;
        z-index: 50;
        margin: 0;
        .forward_nav_item:last-child {
            margin: 0 auto;
        }
        .forward_nav_item {
            display: block;
            width: 25px;
            height: 25px;
            background-color: #4B5669;
            -webkit-border-radius: 50%;
            -moz-border-radius: 50%;
            border-radius: 50%;
            margin: 0 auto 15px;
            cursor: pointer;
            position: relative;
            &:before {
                display: inline-block;
                position: absolute;
                content: ' ';
                font: 0/0 sans-serif;
                width: 0%;
                height: 0%;
                top: 50%;
                left: 50%;
                background-color: #ffffff;
                -webkit-border-radius: 50%;
                -moz-border-radius: 50%;
                border-radius: 50%;
                -webkit-transition: all 0.25s ease-in-out;
                -moz-transition: all 0.25s ease-in-out;
                -o-transition: all 0.25s ease-in-out;
                transition: all 0.25s ease-in-out;
            }

            &:hover {
                &:before {
                    width: 50%;
                    height: 50%;
                    top: 25%;
                    left: 25%;
                }
            }

            &.scrolled_to {
                &:before {
                    display: inline-block;
                    position: absolute;
                    content: ' ';
                    font: 0/0 sans-serif;
                    width: 50%;
                    height: 50%;
                    top: 25%;
                    left: 25%;
                    background-color: #ffffff;
                    -webkit-border-radius: 50%;
                    -moz-border-radius: 50%;
                    border-radius: 50%;
                    -webkit-transition: all 0.25s ease-in-out;
                    -moz-transition: all 0.25s ease-in-out;
                    -o-transition: all 0.25s ease-in-out;
                    transition: all 0.25s ease-in-out;
                }
            }
        }
    }

    .forward_content_container {
        width: 100%;
        max-width: 1280px;
        margin: 0 auto;
        position: relative;
        .title {
            color: #ffffff;
        }
    }

    .forward_content_wrapper {
        width: 100%;
        text-align: right;
        .forward_content {
            display: inline-block;
            width: 70%;
            padding: 0 60px 0 0;
            text-align: left;
            font-size: 15px;
            margin: 0;
            @media screen and (max-width:767px) {
                width: 100%;
                padding: 0 50px 0 20px;
            }
        }

        &.alternative_bg {
            position: relative;
            &:before {
                content: ' ';
                font: 0/0 sans-serif;
                position: absolute;
                top: 0;
                left: -200%;
                width: 200%;
                height: 100%;
                display: block;
                zoom: 1;
                visibility: visible;
                z-index: 0;
                background-position: top right;
            }
            &:after {
                content: ' ';
                font: 0/0 sans-serif;
                position: absolute;
                top: 0;
                right: -200%;
                width: 200%;
                height: 100%;
                display: block;
                zoom: 1;
                visibility: visible;
                z-index: 0;
            }
            &.first, &.first:after {
                background-color: #957AFF;
            }
            &.first:before {
                background-color: #957AFF;
            }
            &.second, &.second:after {
                background-color: #3F82AB;
            }
            &.second:before {
                background-color: #3F82AB;
            }
            &.third, &.third:after {
                background-color: #3FAB80;
            }
            &.third:before {
                background-color: #3FAB80;
            }
            &.fourth, &.fourth:after {
                background-color: #967B5C;
            }
            &.fourth:before {
                background-color: #967B5C;
            }
        }

        .forward_scroll_arrow {
            text-align: center;
            margin-top: 20%;
            .arrow {
                cursor: pointer;
                width: 100%;
                height: 100%;
                max-width: 111px;
                max-height: 111px;
                @media screen and (max-width:767px) {
                    width: 25%;
                }
            }
        }

        &.forward_header {
            max-width: 1920px;
            line-height: 0;
            margin: 0 auto;
            .header_content {
                width: 100%;
                text-align: center;
                padding: 0;
                .header_title {
                    font: 400 33px/1.4 'Open Sans', sans-serif;
                    padding: 0 75px;
                    color: #ffffff;
                }

                .header_container {
                    position: absolute;
                    top: 0;
                    width: 100%;
                    max-width: 960px;
                    height: 100%;
                    left: 50%;
                    margin-left: -480px;
                    @media screen and (max-width:959px) {
                        margin-left: -50%;
                    }
                }

                .header_image {
                    position: relative;
                    width: 100%;
                    height: 740px;
                    max-height: 740px;
                    padding-bottom: 0;
                    background: url('https://i.imgur.com/9685CtV.jpg') no-repeat top center scroll;
                    -webkit-background-size: cover;
                    -moz-background-size: cover;
                    -o-background-size: cover;
                    background-size: cover;
                    @media screen and (max-width:1365px) {
                        height: 100%;
                        padding-bottom: 60%;
                    }
                    @media screen and (max-width:479px) {
                        padding-bottom: 80%;
                    }
                }

                .forward_headline {
                    width: 60%;
                    max-width: 559px;
                    text-align: left;
                    background-color: rgb(75, 86, 105);
                    background-color: rgba(75, 86, 105, 0.5);
                    padding: 20px;
                    margin: 10% 0 0;
                    @media screen and (max-width:767px) {
                        padding: 10px;
                    }
                    @media screen and (max-width:479px) {
                        width: 90%;
                        padding: 10px 20px;
                    }

                    h2 {
                        font: 400 45px/1 'Open Sans', sans-serif;
                        margin: 0 0 20px;
                        text-transform: uppercase;
                        @media screen and (max-width:1023px) {
                            font-size: 33px;
                            margin: 0 0 15px;
                        }
                        @media screen and (max-width:767px) {
                            font-size: 22px;
                            margin: 0 0 10px;
                        }
                        @media screen and (max-width:479px) {
                            font-size: 18px;
                            margin-bottom: 5px;
                        }
                    }

                    p {
                        font: 400 25px/1 'Open Sans', sans-serif;
                        @media screen and (max-width:1023px) {
                            font-size: 22px;
                        }
                        @media screen and (max-width:767px) {
                            font-size: 14px;
                        }
                    }
                }

                .header_store_buttons {
                    position: absolute;
                    top: 60%;
                    left: 0;
                    margin-left: 20px;
                    width: 100%;
                    text-align: left;
                    @media screen and (max-width:1365px) {
                        top: 62%;
                    }
                    @media screen and (max-width:1024px) {
                        top: 70%;
                    }
                    @media screen and (max-width:479px) {
                        top: 75%;
                    }

                    .header_store_button {
                        padding: 0;
                        display: inline-block;
                        &.appstore {
                            width: 21.6666%;
                            max-width: 208px;
                            min-width: 110px;
                            margin: 0 30px 30px 0;
                        }

                        &.googleplay {
                            width: 18.6458%;
                            max-width: 179px;
                            min-width: 95px;
                        }
                        img {
                            width: 100%;
                            height: auto;
                        }
                    }
                }

                .header_social {
                    position: absolute;
                    bottom: 24%;
                    left: 0;
                    margin-left: 20px;
                    @media screen and (max-width:1024px) {
                        bottom: 8%;
                    }
                    @media screen and (max-width:479px) {
                        bottom: 2%;
                    }

                    .fb_container {
                        display: inline-block;
                        width: 46px;
                        overflow: hidden;
                    }
                }
            }
        }

        &.forward_footer {
            background-color: #911111;
            position: relative;
            z-index: 15;
            text-align: left;

            .footer_content {
                padding: 80px 20px 60px;
                width: 60%;
                @media screen and (max-width:767px) {
                    padding: 10% 20px 40px;
                    width: 100%;
                }

                .title {
                    line-height: 1;
                    margin: 0 0 10px;
                    @media screen and (max-width:767px) {
                        font-size: 33px;
                    }
                }

                .description {
                    font: 400 25px/1 'Open Sans', sans-serif;
                    margin: 0 0 60px;
                    @media screen and (max-width:767px) {
                        font-size: 18px;
                        margin: 0 0 30px;
                    }
                }
            }

            &:before {
                content: ' ';
                font: 0/0 sans-serif;
                position: absolute;
                background-color: #911111;
                top: 0;
                left: -200%;
                width: 200%;
                height: 100%;
                display: block;
                zoom: 1;
                visibility: visible;
                z-index: 0;
            }
            &:after {
                content: ' ';
                font: 0/0 sans-serif;
                position: absolute;
                background-color: #911111;
                top: 0;
                right: -200%;
                width: 200%;
                height: 100%;
                display: block;
                zoom: 1;
                visibility: visible;
                z-index: 0;
            }
        }
    }

    .forward_phone {
        display: inline-block;
        width: 25%;
        max-width: 300px;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1;
        @media screen and (max-width:767px) {
            visibility: hidden;
            -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
            filter: alpha(opacity=0);
            -moz-opacity: 0;
            -khtml-opacity: 0;
            opacity: 0;
        }
        .forward_mockup_container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            .forward_mockup {
                width: 100%;
                height: auto;
            }
            .forward_phone_shadow {
                position: absolute;
                bottom: -10%;
                left: 50%;
                margin-left: -55%;
                width: 110%;
                max-width: 427px;
                height: auto;
                z-index: 10;
            }
        }

        .forward_slides_container {
            margin-top: 21.9827%;
            overflow: hidden;
            .forward_phoneslide {
                display: block;
                padding: 0 6.25% 0 5.0646%;
                .slide {
                    display: block;
                    width: 100%;
                    height: 100%;
                }
            }
        }
    }

    .title {
        font: 400 46px/1.15 'Open Sans', sans-serif;
        color: #e10074;
        margin: 0 0 20px;
        @media screen and (max-width:479px) {
            font-size: 33px;
        }
    }

    .description {
        font: 400 18px/1.3 'Open Sans', sans-serif;
        margin: 0;
        @media screen and (max-width:479px) {
            font-size: 16px;
        }
    }
}
            
          
!
            
              $(document).ready(function () {

    // lock scroll
    var scrollPosition = [
    self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
    self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop];
    var html = $('html');
    html.data('scroll-position', scrollPosition);
    html.data('previous-overflow', html.css('overflow'));
    html.css('overflow', 'hidden');
    window.scrollTo(scrollPosition[0], scrollPosition[1]);
    $('html, body').mousedown(function (e) {
        if (e.button == 1) return false;
    });
    $('html, body').on('touchmove', function(e){
         e.preventDefault();
    });

    // responsive resizing
    function responsiveResize() {

        // get device and content height and calculate content areas
        var deviceHeight = $(window).height();
        var phoneOuterHeight = $('.forward_mockup').height();
        var slideHeight = $('.forward_phoneslide').height();

        if (!(window.mozInnerScreenX == null) || !jQuery.support.leadingWhitespace) {
            var phoneMargin = (parseInt($('.forward_content_container').offset().left)+25);
        } else {
            var phoneMargin = (parseInt($('.forward_content_container').css('marginLeft'))+25);
        }

        var slideIncrement = slideHeight;

        $('.forward_phone').css('left', phoneMargin);
        $('.forward_phone').css('height', phoneOuterHeight);
        $('.forward_slides_container').css('height', slideHeight);

        $(".normal_content").each(function() {
            var contentHeight = $(this).height();
            $(this).css('padding-top', Math.round((deviceHeight - contentHeight) / 2));
            $(this).css('padding-bottom', Math.round((deviceHeight - contentHeight) / 2));
        });

        phoneOffset = (deviceHeight - $('.forward_mockup_container').height())/2;
        $('.forward_phone').css('top', phoneOffset);
        if ($('.active').hasClass("fake_slide")) {
            $(".forward_phone").css('margin-top', phoneOuterHeight - phoneOffset*0.5);
        }

        var headerHeight = $('.header_content').height();

        // recalculate current slide margintop
        if (!$('.active').hasClass("fake_slide")) {
            if ($('.active').hasClass('first_slide')) {
                $("#slide1").css('margin-top', '0px');
            } else if ($('.active').hasClass("fake_slide_footer")) {
                $("#slide1").css('margin-top', -Math.round(slideIncrement*(currentContent -2)));
            } else {
                $("#slide1").css('margin-top', -Math.round(slideIncrement*(currentContent -1)));
            }
        }

        if ($('.forward_nav').css('position') == 'fixed') {
            if (!(window.mozInnerScreenX == null) || !jQuery.support.leadingWhitespace) {
                navMargin = (parseInt($('.forward_content_container').offset().left));
            } else {
                navMargin = (parseInt($('.forward_content_container').css('marginLeft')));
            }
            $('.forward_nav').css('margin-right', navMargin);
        }

        // recalculate nav margin
        var navHeight = ($('.forward_nav').height() + 20);
        var navOffset = ($(window).height() - navHeight) / 2;
        $('.forward_nav').css('top', navOffset);

        // keep scroll at the top of current content
        var currentTop = $('.forward_scroll').find('.forward_phoneslide.active, .fake_slide.active, .fake_slide_footer.active').attr('id').replace('slide','');
        $('html, body').stop().animate({
            scrollTop: $('#content'+currentTop).offset().top
        }, 10);
    }

    // initial calculations
    $(window).load(function() {
        // generate navigation
        $(".forward_content").each(function() {
            if (!$(this).hasClass('footer_content')) {
                var navigationID = $(this).attr('id').replace('content','');
                $(".forward_nav").append('<li class="forward_nav_item" id="forward_nav' + navigationID + '"></li>');
            }
        });
        $("#forward_nav0").addClass('scrolled_to');
        var navHeight = ($('.forward_nav').height() + 20);
        var navOffset = ($(window).height() - navHeight) / 2;
        $('.forward_nav').css('top', navOffset);

        responsiveResize();

        // reset on page load
        $('html, body').stop().animate({
            scrollTop: $('.forward_wrapper').scrollTop()
        }, 10);
    });

    // detect resize
    $(window).on('resize', function () {
        responsiveResize();
    });

    // recalculate on device orientation change
    if (window.addEventListener) {
        window.addEventListener("orientationchange", function() {
            setTimeout(function () {
                responsiveResize();
            }, 100);
        });
    } else {
        window.attachEvent("orientationchange", function() {
            setTimeout(function () {
                responsiveResize();
            }, 100);
        });
    }

    // detect device orientation change
    if (window.addEventListener) {
        window.addEventListener("orientationchange", function() {
            responsiveResize();
            var orientation = Math.abs(window.orientation) == 90 ? 'landscape' : 'portrait';
            var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone");
            var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad");
            var isiPod = navigator.userAgent.toLowerCase().indexOf("ipod");
            // if ( (orientation == 'landscape' && isiPhone > -1) || (orientation == 'landscape' && isiPad > -1) || (orientation == 'landscape' && isiPod > -1) ) {
            if ( orientation == 'landscape' ) {
                var deviceWidth = $(window).width();
                phoneOffset = (deviceWidth - $('.forward_mockup_container').height())/2;
                $('.forward_phone').css('top', phoneOffset);
            }
        }, false);
    } else {
        window.attachEvent("orientationchange", function() {
            responsiveResize();
        });
    }

    // globals for main function
    var stop = false;
    var slideOffset = 0;
    var navSlideOffset = 0;
    var contentNumber = ($('.forward_content').length - 1);
    var currentContent = 0;
    var swiped = false;
    var swipedUp = false;
    var swipedDown = false;
    var scrollDistance = 0;
    var navitemScroll = 0;
    var navScrollDistance = 0;
    var currentNav = 0;
    var navDiff = 0;
    var phoneOffset = 0;
    var navMargin = 0;
    var navHeight = 0;
    var navOffset = 0;

    // main function
    function mainScroll(e) {
        var phoneHeight = $('.forward_phoneslide').height();
        var phoneOuterHeight = $('.forward_mockup').height();
        var slideIncrement = phoneHeight;

        if (swiped === true) {
            if (swipedUp === true) {
                var delta = -1;
            } else if (swipedDown === true) {
                var delta = 1;
            }
        } else {
            if (!(window.mozInnerScreenX == null)) {
                var delta = -(e.originalEvent.detail);
            } else {
                var delta = e.originalEvent.wheelDelta;
            }
        }

        if (delta < 0 && stop === false && currentContent >= 0 && currentContent < contentNumber) {
            stop = true;
            slideOffset = -(parseInt($("#slide1").css('margin-top'))) + slideIncrement;
            $('.forward_nav_item').removeClass('scrolled_to');

            if ( currentContent == 1 ) {
                if (!(window.mozInnerScreenX == null) || !jQuery.support.leadingWhitespace) {
                    navMargin = (parseInt($('.forward_content_container').offset().left));
                } else {
                    navMargin = (parseInt($('.forward_content_container').css('marginLeft')));
                }
                $('.forward_nav').css('position', 'fixed');
                $('.forward_nav').css('margin-right', navMargin);
            }

            if ( currentContent == 0 ) {
                $(".forward_phone").stop().velocity({
                    marginTop: 0
                }, 900);
                $('#slide'+currentContent).removeClass('active');
                currentContent++;
                $('#slide'+currentContent).addClass('active');
                $('#forward_nav'+currentContent).addClass('scrolled_to');
                scrollDistance = $('#content'+currentContent).offset().top;
                $('html, body').stop().animate({
                    scrollTop: scrollDistance
                }, {
                    duration: 1000,
                    complete: function () {
                        stop = false;
                    }
                });
            } else {
                $('#slide'+currentContent).removeClass('active');
                currentContent++;
                $('#slide'+currentContent).addClass('active');
                $('#forward_nav'+currentContent).addClass('scrolled_to');
                scrollDistance = $('#content'+currentContent).offset().top;

                if (currentContent != 5) {
                    $("#slide1").stop().velocity({
                        marginTop: -Math.round(slideOffset)
                    }, 900);
                } else {
                    $(".forward_phone").stop().velocity({
                        marginTop: -phoneOffset*0.9
                    }, 850);
                    $(".forward_nav").stop().velocity({
                        marginTop: -phoneOffset*1.85
                    }, 850);
                }

                $('html, body').stop().animate({
                    scrollTop: scrollDistance
                }, {
                    duration: 1000,
                    complete: function () {
                        stop = false;
                    }
                });
            }

        } else if (delta > 0 && stop === false && currentContent > 0 && currentContent <= contentNumber) {
            stop = true;
            slideOffset = -(parseInt($("#slide1").css('margin-top'))) - slideIncrement;
            $('.forward_nav_item').removeClass('scrolled_to');

            if ( currentContent == 2 ) {
                setTimeout(function () {
                    $('.forward_nav').css('position', 'absolute');
                    $('.forward_nav').css('margin-right', 0);
                }, 1010);
            }

            if ( currentContent == 1 ) {
                $(".forward_phone").stop().velocity({
                    marginTop: phoneOuterHeight - phoneOffset*0.5
                }, 900);
                $('#slide'+currentContent).removeClass('active');
                currentContent--;
                $('#slide'+currentContent).addClass('active');
                $('#forward_nav'+currentContent).addClass('scrolled_to');
                scrollDistance = $('#content'+currentContent).offset().top;
                $('html, body').stop().animate({
                    scrollTop: scrollDistance
                }, {
                    duration: 1000,
                    complete: function () {
                        stop = false;
                    }
                });
            } else {
                $('#slide'+currentContent).removeClass('active');
                currentContent--;
                $('#slide'+currentContent).addClass('active');
                $('#forward_nav'+currentContent).addClass('scrolled_to');
                scrollDistance = $('#content'+currentContent).offset().top;

                if (currentContent != 4) {
                    $("#slide1").stop().velocity({
                        marginTop: -Math.round(slideOffset)
                    }, 900);
                } else {
                    $(".forward_phone, .forward_nav").stop().velocity({
                        marginTop: 0
                    }, 850);
                }

                $('html, body').stop().animate({
                    scrollTop: scrollDistance
                }, {
                    duration: 1000,
                    complete: function () {
                        stop = false;
                    }
                });
            }
        }

        swiped = false;
        swipedUp = false;
        swipedDown = false;
    }

    // nav function
    function navScroll() {
        var phoneHeight = $('.forward_phoneslide').height();
        var slideIncrement = phoneHeight;
        var phoneOuterHeight = $('.forward_mockup').height();
        navScrollDistance = $('#content'+navitemScroll).offset().top;
        currentNav = $('.forward_scroll').find('.forward_phoneslide.active, .fake_slide.active, .fake_slide_footer.active').attr('id').replace('slide','');
        navDiff = Math.abs(currentNav - navitemScroll);
        currentContent = navitemScroll;

        if (stop === false) {
            stop = true;
            $('.forward_nav_item').removeClass('scrolled_to');
            $('#forward_nav'+navitemScroll).addClass('scrolled_to');
            $('.forward_scroll').find('.forward_phoneslide.active, .fake_slide.active, .fake_slide_footer.active').removeClass('active');
            $('html, body').stop().animate({
                scrollTop: navScrollDistance
            }, {
                duration: 900*navDiff,
                complete: function () {
                    stop = false;
                },
                step: function ( num ) {
                    if ( navitemScroll == 0 ) {
                        screenNow = num;
                        var navReset = $('.header_content').height();
                        if ( screenNow > navReset - 15 && screenNow < navReset + 15 ) {
                            $('.forward_nav').css('position', 'absolute');
                            $('.forward_nav').css('margin-right', 0);
                        }
                    }
                }
            });

            if ( navitemScroll < currentNav && navitemScroll != 0 && currentNav != 0 ) {
                navSlideOffset = Math.abs(slideIncrement*(1 - navitemScroll));
                $("#slide1").stop().velocity({
                    marginTop: -Math.round(navSlideOffset)
                }, 850*navDiff);
                if ( currentNav == 5 ) {
                    $(".forward_phone, .forward_nav").stop().velocity({
                        marginTop: 0
                    }, 850);
                }

            } else if ( navitemScroll > currentNav && navitemScroll != 0 && currentNav != 0 ) {
                navSlideOffset = Math.abs(parseInt($("#slide1").css('margin-top'))) + slideIncrement*navDiff;
                $("#slide1").stop().velocity({
                    marginTop: -Math.round(navSlideOffset)
                }, 850*navDiff);

            } else if ( navitemScroll == 0 ) {
                $("#slide1").stop().velocity({
                    marginTop: 0
                }, 850*navDiff);
                $(".forward_phone").stop().velocity({
                    marginTop: phoneOuterHeight - phoneOffset*0.5
                }, 1000*navDiff);

                if ( currentNav == 5 ) {
                    $(".forward_nav").animate({
                        marginTop: 0
                    }, 850);
                }

            } else if ( currentNav == 0 ) {
                navSlideOffset = Math.abs(slideIncrement*(navDiff - 1));
                $("#slide1").stop().velocity({
                    marginTop: -Math.round(navSlideOffset)
                }, 850*navDiff);
                $(".forward_phone").stop().velocity({
                    marginTop: 0
                }, 1000);

                setTimeout(function () {
                    if (!(window.mozInnerScreenX == null) || !jQuery.support.leadingWhitespace) {
                        navMargin = (parseInt($('.forward_content_container').offset().left));
                    } else {
                        navMargin = (parseInt($('.forward_content_container').css('marginLeft')));
                    }
                    var navOffsetTopM = $(window).height()*(navDiff - 1);
                    $(".forward_nav").stop().animate({
                        marginTop: navOffsetTopM
                    }, {
                        duration: 800*navDiff,
                        complete: function () {
                            $('.forward_nav').css('position', 'fixed');
                            $('.forward_nav').css('margin-top', 0);
                            $('.forward_nav').css('margin-right', navMargin);
                        }
                    });
                }, 450);
            }

            if ( currentNav == 1 && navitemScroll > 1 ) {
                if (!(window.mozInnerScreenX == null) || !jQuery.support.leadingWhitespace) {
                    navMargin = (parseInt($('.forward_content_container').offset().left));
                } else {
                    navMargin = (parseInt($('.forward_content_container').css('marginLeft')));
                }
                $('.forward_nav').css('position', 'fixed');
                $('.forward_nav').css('margin-right', navMargin);
            }

            $('#slide'+navitemScroll).addClass('active');
        }
    }

    // chrome,ie,opera detect scroll attempt and scroll
    $('html').on('mousewheel', function (e) {
        mainScroll(e);
    });

    // firefox detect scroll attempt and scroll
    $('html').on('DOMMouseScroll', function (e) {
        mainScroll(e);
    });

    // swipe detect and scroll
    $('body').swipe( {
        swipeUp:function(event, direction, distance, duration, fingerCount) {
            swiped = true;
            swipedUp = true;
            swipedDown = false;
            mainScroll();
        },
        swipeDown:function(event, direction, distance, duration, fingerCount) {
            swiped = true;
            swipedUp = false;
            swipedDown = true;
            mainScroll();
        }
    });

    // nav click and scroll
    $('.forward_nav').delegate('.forward_nav_item', 'click touchstart', function() {
        navitemScroll = $(this).attr('id').replace('forward_nav','');
        navScroll();
    });

    // up down arrow and scroll
    $(document).on("keydown", function(e){
        if(e.keyCode === 38) {
            // up
            swiped = true;
            swipedUp = false;
            swipedDown = true;
            mainScroll();
        } else if (e.keyCode === 40) {
            // down
            swiped = true;
            swipedUp = true;
            swipedDown = false;
            mainScroll();
        }
        e.preventDefault();
    });

    // arrow click and scroll
    $('.arrow').on('click touchstart', function() {
        if ( stop === false ) {
            stop = true;
            var arrowScroll = $(this).attr('id').replace('arrow','');
            var phoneHeight = $('.forward_phoneslide').height();
            var phoneOuterHeight = $('.forward_mockup').height();
            var slideIncrement = phoneHeight;
            slideOffset = -(parseInt($("#slide1").css('margin-top'))) + slideIncrement;

            if ( arrowScroll == 1 ) {
                if (!(window.mozInnerScreenX == null) || !jQuery.support.leadingWhitespace) {
                    navMargin = (parseInt($('.forward_content_container').offset().left));
                } else {
                    navMargin = (parseInt($('.forward_content_container').css('marginLeft')));
                }
                $('.forward_nav').css('position', 'fixed');
                $('.forward_nav').css('margin-right', navMargin);
            }

            $('#slide'+arrowScroll).removeClass('active');
            $('#forward_nav'+arrowScroll).removeClass('scrolled_to');
            arrowScroll++;
            $('#slide'+arrowScroll).addClass('active');
            $('#forward_nav'+arrowScroll).addClass('scrolled_to');
            currentContent = arrowScroll;

            scrollDistance = $('#content'+arrowScroll).offset().top;
            $('html, body').stop().animate({
                scrollTop: scrollDistance
            }, {
                duration: 1000,
                complete: function () {
                    stop = false;
                }
            });

            if (arrowScroll != 5) {
                $("#slide1").stop().velocity({
                    marginTop: -Math.round(slideOffset)
                }, 900);
            } else {
                $(".forward_phone").stop().velocity({
                    marginTop: -phoneOffset*0.9
                }, 850);
                $(".forward_nav").stop().velocity({
                    marginTop: -phoneOffset*1.85
                }, 850);
            }
        }
    });
});
            
          
!
999px
🕑 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.

Console