Giter Site home page Giter Site logo

mattsmedium.js's Introduction

Matts Medium

A jQuery plugin to make a parallax intro slide like medium.com

Features

  • Uses hardware accelerated 3D Transform as to animate the background. All the work is offloaded to the GPU.
  • Only animates the image when its within the viewport.
  • Scrolling is debounced to requestAnimationFrame for maximum scrolling efficiency.

Example use

<!DOCTYPE html>
<html>
<head>
<style>
.introSlide {
    position: fixed;
    height:90%;
    width:100%;
    overflow: hidden;
    z-index: 0;
    background: #000;
}
.introParent {
    position: absolute;
    display:table;
    width:100%;
    height:100%;
    top:0;
    z-index: 2;
    text-align: center;
}
.introChild {
    display: table-cell;
    vertical-align: middle;
    height:100%;
}
.introChildPadding {
    padding:0 10%;    
}
.introImage {
    position: absolute;
    background: 0 0 no-repeat fixed;
    background-size: cover;
    height:100%;
    width:100%;
    top:0;
    z-index: 0;
    opacity: 0.7;
}


/*
Wrap the content of your document in an ID called root.
Give it a class of shortIntro to make it 50% height of the page.
*/

#root {
    top:90%;
    width:100%;
    z-index: 1;
    position: absolute;
    height:auto;
    background: #fff;
}
#root.shortIntro {
    top:50%;  
}
.introSlide.shortIntro {
    height:50%; 
}

</style>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="jquery.mattsmedium.min.js"></script>
</head>
<body>

<section class="introSlide">
	<div class="introParent" data-mattsMediumFront>
		<div class="introChild">
			<h1>Content</h1>
		</div>
	</div>
	<div class="introImage" data-mattsMediumBackDarken="20" style="background-image:url(http://placekitten.com/1200/1200)"></div>
</section>

<div id="root" class="shortIntro">
	Your site content goes here.
</div>

<script>

$(".introSlide").mattsMedium(40);

</script>
</body>
</html>

mattsmedium.js's People

Contributors

matthewnolan avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.