You Might Also Like

Showing posts with label Education. Show all posts
Showing posts with label Education. Show all posts

Sunday, September 15, 2013

Tutorial Add a Progress Bar to Your Site

DEMO          DOWNLOAD

Since the advent of mobile, web sites are turning more and more into “apps”. Concepts that make sense for a locally running application are transferred to the web. One of these is the recent addition of “progress bars” to some of Google’s websites that show the loading state of the page.
In this quick tip, we will use the new NProgress jQuery plugin to add a progress bar to a web page. If you’d like to learn more, keep reading!

The NProgress Plugin

NProgress is a jQuery plugin that shows an interactive progress bar on the top of your page, inspired by the one on YouTube. It consists of a global object – NProgress which holds a number of methods that you can call to advance the progress bar. Here is a quick demo of the methods:

<div>
    <h1>Quick Load</h1>
    <p>Show the progress bar quickly. This is useful for one-off tasks like AJAX requests and page loads.</p>
    <button class="quick-load">Quick Load</button>
</div>

<div>
    <h1>Incremental Load</h1>
    <p>The progress bar is incremented with every element that is loaded. This can be useful in web apps that load multiple items.</p>
    <button class="show-progress-bar">Show Progress Bar</button>
    <button class="load-one-item">Load An Item</button>
    <button class="finish">Finish Loading</button>
</div>

<div>
    <h1>Percentage Load</h1>
    <p>NProgress lets you set the progress bar to a specific percentage. This can be useful in apps where you know the total number of the items to be loaded, so you can calculate the percentage. This is the technique that we will use in the demo.</p>
    <button class="show-progress-bar">Show Progress Bar</button>
    <button class="set-to-25">Set to 25% Loaded</button>
    <button class="set-to-75">Set to 75% Loaded</button>
    <button class="finish">Finish Loading</button>
</div>

The plugin github page suggests that you hook up the NProgress.start() function to your $(document).ready() callback and NProgress.done() to $(window).load() which is a very easy way to integrate the plugin. This won’t show the real progress (for that you will have to monitor all the resources that are included in your page and increment the bar manually), however most people won’t notice anyway.
Now that you have a good idea of how NProgress is used, let’s make a more complicated example – a gallery that shows a progress bar while loading images. The bar will correspond to the actual number of images loaded.

The Gallery

As usual, we start off with the HTML markup. This time it is very simple, we only have need a div to hold the photos, and a load button:

index.html

<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8"/>
        <title>Quick Tip: Add a Progress Bar to Your Site</title>

        <link href="http://fonts.googleapis.com/css?family=PT+Sans+Narrow:700" rel="stylesheet" />

        <!-- The Stylesheets -->
        <link href="assets/nprogress/nprogress.css" rel="stylesheet" />
        <link href="assets/css/style.css" rel="stylesheet" />

    </head>

    <body>

        <h1>Gallery Progress Bar</h1>

        <div id="main"></div>

        <a href="#" id="loadMore">Load More</a>

        <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="assets/nprogress/nprogress.js"></script>
        <script src="assets/js/script.js"></script>

    </body>
</html>
I am including a custom font from Google Webfonts and two stylesheets in the <head>, and three JavaScript files before the closing </body> tag.

Things get more interesting in the jQuery part of the tutorial. Here I am using the Deferred object to show the photos consecutively. This is needed, because we want the photos to download in parallel (which is much faster), but fade into view one after the other. This article is too short to explain how Deferreds work, but you can read through one of these: link, link, link. They are a powerful tool that can simplify asynchronous interactions.

assets/js/script.js

(function($){

    // An array with photos to show on the page. Instead of hard 
    // coding it, you can fetch this array from your server with AJAX.

    var photos = [
        'assets/photos/1.jpg',	'assets/photos/2.jpg',
        'assets/photos/3.jpg',	'assets/photos/4.jpg',
        // more photos here
    ];

    $(document).ready(function(){		

        // Define some variables

        var page = 0,
            loaded = 0,
            perpage = 10,
            main = $('#main'),
            expected = perpage,
            loadMore = $('#loadMore');

        // Listen for the image-loaded custom event

        main.on('image-loaded', function(){

            // When such an event occurs, advance the progress bar

            loaded++;

            // NProgress.set takes a number between 0 and 1
            NProgress.set(loaded/expected);

            if(page*perpage >= photos.length){

                // If there are no more photos to show,
                // remove the load button from the page

                loadMore.remove();
            }
        });

        // When the load button is clicked, show 10 more images 
        // (controlled by the perpage variable)

        loadMore.click(function(e){

            e.preventDefault();

            loaded = 0;
            expected = 0;

            // We will pass a resolved deferred to the first image,
            // so that it is shown immediately.
            var deferred = $.Deferred().resolve();

            // Get a slice of the photos array, and show the photos. Depending
            // on the size of the array, there may be less than perpage photos shown

            $.each(photos.slice(page*perpage, page*perpage + perpage), function(){

                // Pass the deferred returned by each invocation of showImage to 
                // the next. This will make the images load one after the other:

                deferred = main.showImage(this, deferred);

                expected++;
            });

            // Start the progress bar animation
            NProgress.start();

            page++;
        });

        loadMore.click();
    });

    // Create a new jQuery plugin, which displays the image in the current element after
    // it has been loaded. The plugin takes two arguments:
    //	* src - the URL of an image
    //	* deferred - a jQuery deferred object, created by the previous call to showImage
    // 
    // Returns a new deferred object that is resolved when the image is loaded.

    $.fn.showImage = function(src, deferred){

        var elem = $(this);

        // The deferred that this function will return

        var result = $.Deferred();

        // Create the photo div, which will host the image

        var holder = $('<div class="photo" />').appendTo(elem);

        // Load the image in memory

        var img = $('<img>');

        img.load(function(){

            // The photo has been loaded! Use the .always() method of the deferred
            // to get notified when the previous image has been loaded. When this happens,
            // show the current one.

            deferred.always(function(){

                // Trigger a custom event on the #main div:
                elem.trigger('image-loaded');

                // Append the image to the page and reveal it with an animation

                img.hide().appendTo(holder).delay(100).fadeIn('fast', function(){

                    // Resolve the returned deferred. This will notifiy
                    // the next photo on the page and call its .always() callback

                    result.resolve()
                });
            });

        });

        img.attr('src', src);

        // Return the deferred (it has not been resolved at this point)
        return result;
    } 

})(jQuery);
The progress bar is incremented with every loaded image by the callback function that listens for the image-loaded custom event. This way the showImage function is free to handle only the loading and displaying of the photos.
by Martin Angelov
source: http://tutorialzine.com/2013/09/quick-tip-progress-bar/





Friday, September 13, 2013

How to Get Started With HTML5 Game Development



Learn how to get started with HTML5 game development from this guide by Austin Hallock and Robert Nyman.

Most of the audience here already sees the value in HTML5, but I want to re-iterate why you should be building an HTML5 game. If you are just targeting iOS for your game, write the game in Objective-C, the cons outweigh the benefits in that scenario… but if you want to build a game that works on a multitude of platforms, HTML5 is the way to go.

Cross-Platform

One of the more obvious advantages of HTML5 for games is that the games will work on any modern device. Yes, you will have to put extra thought into how your game will respond to various screen sizes and input types, and yes, you might have to do a bit of ‘personalization’ in the code per platform (the main inhibitor being audio); but it’s far better than the alternative of completely porting the game each time.
I see too many games that don’t work on mobile and tablets, and in most instances that really is a huge mistake to make when developing your game – keep mobile in mind when developing your HTML5 game!

Unique Distribution

Most HTML5 games that have been developed to this point are built in the same manner as Flash and native mobile games. To some extent this makes sense, but what’s overlooked is the actual benefits The Web as a platform adds. It’s like if an iOS developer were to build a game that doesn’t take advantage of how touch is different from a mouse – or if Doodle Jump was built with arrow keys at the bottom of the screen instead of using the device’s accelerator.
It’s so easy to fall into the mindset of doing what has worked in the past, but that stifles innovation. It’s a trap I’ve fallen into – trying to 100% emulate what has been successful on iOS, Android, and Flash – and it wasn’t until chatting with former Mozillian Rob Hawkes before I fully realized it. While emulating what worked in the past is necessary to an extent, The Open Web is a different vehicle for games, and innovation can only happen when taking a risk and trying something new.
Distribution for HTML5 games is often thought of as a weakness, but that’s just because we’ve been looking at it in the same sense as native mobile games, where a marketplace is the only way to find games. With HTML5 games you have the incredible powerful hyperlink. Links can so easily be distributed across the web and mobile devices (think of how many links you click in the Facebook and Twitter apps), and it certainly should not just be limited to the main page for the game. The technology is there to be able to link to your game and do more interesting things like jump to a specific point in a game, try to beat a friend’s score, or play real-time against that friend – use it to your advantage!
Take a good look at was has worked for the virality of websites and apply those same principles to your games.

Quicker Development Process

No waiting for compilation, updates and debugging in real-time, and once the game is done, you can push out the update immediately.

Choosing a Game Engine

Game engines are just one more level of abstraction that take care of a few of the more tedious tasks of game development. Most take care of asset loading, input, physics, audio, sprite maps and animation, but they vary quite a bit. Some engines are pretty barebones, while some (ImpactJS for example) go as far as including a 2D level editor and debug tools.

Decide Whether or Not You Need a Game Engine

This is largely a personal decision. Game Engines will almost always reduce the time it takes for you to create a fully-functional game, but I know some folks just like the process of building everything from the ground up so they can better understand every component of the game.
For simple games, it really isn’t difficult to build from scratch (assuming you have a JavaScript background and understand how games work). Slime Volley (source) for example was built without having a game engine, and none of the components were rocket science. Of course, Slime Volley is a very basic game, building an RPG from the ground up would likely lead to more hair pulling.

Choosing Between a “Game Engine” and a “Game Maker”

Most of the typical audience of Mozilla Hacks are probably going to lean toward using a game engine or building from scratch, but there is also the alternative of using a “Game Maker” like Construct 2. Using a Game Maker means you won’t actually write in JavaScript; instead, you create code-like events in the editor. It’s a trade of ease-of-use and quickness to prototype/develop vs customization and control over the end result. I’ve seen some very impressive games built with either, but as a developer-type, I tend to favor writing from scratch / using an engine.

Finding the Right Game Engine / Game Maker for you

There are so many HTML5 game engines out there, which in part is a good thing, but can also be a bad thing since a large percentage have either already stopped being maintained, or will soon stop being maintained. You definitely want to pick an engine that will continually be updated and improved over the years to come.


HTML5GameEngine.com is a great place to start your search because the hundreds of game engines are narrowed down to about 20 that are established, actively maintained, and have actual games being developed with them.
For a more complete list of engines (meaning there can be some junk to sift through), this list on GitHub is your best bet.

Learning Tools

If you’re going with a game engine, typically their site is the best resource with tutorials and documentation.

Technical Tutorials

Game Design Tutorials

With game development, the technical aspect isn’t everything – what’s more important is that the game actually be fun. Below are a few places to start when learning about game mechanics.

Helpful Game Tools

User Retention, Monetization and more

Full disclosure here: I am a co-founder at Clay.io.
Making a game function is just part of the equation. You also want players to play longer, come back, tell their friends about it, and maybe even buy something. Common elements in games that focus on these areas are features like user accounts, high scores, achievements, social integration, and in-game payments. On the surface most are typically easy enough to implement, but there are often many cross-platform issues and intricacies that are overlooked. There is also value in having a central service running these across many games – for example, players genuinely care about achievements on Xbox Live because Gamerscore matters to them.
  • Clay.io – user accounts, high scores, achievements, in-game payments, analytics, distribution, and more.
  • Scoreoid – similar to above.

Development Tools

  • stats.js – A JavaScript performance monitor. Displays framerate, and performance over time.
  • Socket.IO – realtime client-server communication (if you’re going to have a backend for your game).
  • pixi.js – A canvas and WebGL rendering engine.
  • CocoonJS – Improves HTML5 game performance on iOS and Android with an accelerated canvas bound to OpenGL ES.

Motivation

Regardless of what you’re building, extra motivation is always helpful. For games, that motivation often comes from surrounding yourself with others who are in the same boat as you – working on games.

js13kGames

js13kGames is a competition that is currently taking place at the time of this writing. You have until September 13th, 2013 to develop an HTML5 game that, when compressed, is less than 13kb.

Mozilla Game On

Mozilla runs a game competition every year from December through February with some fantastic prizes – last year’s was an all-expense paid, red carpet trip to San Francisco for GDC 2013.

Clay.io’s “Got Game?”

Clay.io (full disclosure, I am a founder) runs an annual HTML5 game development competition for students. Last year was the first year and we had over 70 games submitted. The next competition is planned for February / March 2014.

Ludum Dare

Ludum Dare isn’t for tangible prizes, nor is is specific to HTML5 games, but there are plenty of HTML5 developers that participate.

One Game a Month

One Game a Month isn’t so much a competition as it is an accountability tool. This isn’t restricted to HTML5 games, but many of the participants work with HTML5. The goal is to crank out one game every month. I wouldn’t recommend this long-term since one month is too short of a time to create a great game, but it’s good when learning to force yourself to develop and finish simple games.

Help From the Community

HTML5GameDevs.com

HTML5GameDevs has quickly become the most active community of HTML5 game developers. Most folks are very friendly and willing to help with any issues you run into.

#BBG

#BBG is the go-to IRC channel for HTML5 games – you’ll even find quite a few Mozillians hanging around.

How to Make Money

In-Game Purchases

In-game payments, in my opinion, are the way to go for HTML5 game in the long-term. For now, most HTML5 games don’t have enough quality content, nor the game mechanics in place to get player purchasing items.
This is the revenue model with the highest potential, but it’s also the most difficult to achieve by far – not technically, but having the right game. I’d say the best way to learn how to properly monetize your game in this aspect is to take a look at games that do it really well on Flash and Mobile – games from King.com and Zynga typically have this nailed down pretty well. There’s also some good reading material, like The Top F2P Monetization Tricks on Gamasutra.

Licensing

Where we’re at right now with HTML5 games, licensing games is the strongest, most consistent way to make money – if and only if your game works well on mobile devices.
There are countless “Flash Game Portals” that receive organic mobile traffic, but can’t monetize it with the Flash games they have. Their solution is to go out and find HTML5 games to buy non-exclusive licenses (the right to put the game on their site, often making small adjustments) to offer their mobile visitors.
Typically non-exclusive HTML5 game licenses (meaning you can sell to more than one site) go for $500-$1,000 depending on the game and publisher. Some publishers will do a revenue share model instead where you’ll get a 40-50% share on any advertising revenue, but no up-front money.
Licensing is the safest way to make money right now, but the cap is limited – the most you’re going to make with a single game is in the $5,000-$6,000 range, but it is easier to hit that mark than it is with in-game payments or advertising.

Advertising

Advertising is the middle-ground between in-game payments and licensing. It’s easier than in-game payments to make money and with a higher potential cap than licensing (but probably less than in-game payments). It’s easy enough to implement ads: just pick your ad network of choice (be wary of Adsense’s strict terms) and implement them either surrounding the game, or at various stopping points.
The commonly used ad networks are LeadBolt for mobile and CPMStar for desktop. You can also use Clay.io which makes it a bit easier to implement advertising, and tries to maximize the revenue by using different ad networks depending on the device used and other factors.

Distribution

The final stage in a game’s development is distribution. The game is done, now you want people playing the game! Fortunately, with HTML5 there are plenty of places to have your game (many of which often go unused).
More and more marketplaces these days are accepting HTML5 games as-is. Each has their own requirements (Facebook requires SSL, most require a differently formatted manifest file, etc…), but the time it takes to get into each is typically less than 30 minutes. If you want to reduce that even more, Clay.io helps auto-generate the manifest files and promotional image assets you’ll need (as well as takes care of the SSL requirement) – documentation on that here.

Some marketplaces you’ll need to have a native wrapper for your game – primarily the iOS App Store and Google Play. A wrapper like PhoneGap is one option, but the native webviews have pretty terrible JavaScript engines, so for now you’re better off with tools like CocoonJS and Ejecta.
source: https://hacks.mozilla.org/2013/09/getting-started-with-html5-game-development/

Download Brainy Education Icons


Brainy Icons is a set of 36 hand-drawn free education icons. The icons are available as AI, EPS, PSD and PNG (in 4 sizes: 32×32, 48×48, 64×64, 128×128) and released under the Creative Commons Attribution license.
source: http://handdrawngoods.com/store/brainy-icons-free/

Saturday, August 03, 2013

Tutorial 3D Effect for Mobile App Showcase

DEMO      -      DOWNLOAD

A fancy 3D effect for a mobile app showcase where the app screens animate to a layered stack.
Today we’d like to share an experimental 3D effect with you. It involves a 3D mobile device and some mobile app screenshots. When clicking on a toggle button, we’ll animate the mobie device to rotate and we’ll move each screen so that we have a layered view in the end. You have surely seen this kind of presentation of apps before and we thought it might be fun to do it in CSS.

The idea is to position the mobile device with an slight initial rotation:
appshowcase3d_1
Then we apply a class to the wrapper which will make the device transition to a second position where the screens move out in a layer stack. Effect one is the following:
appshowcase3d_2
The second effect has a different rotation:
appshowcase3d_3
And the third one will also show some labels:
appshowcase3d_4
The screens are anchors so that one can actually link them to eventual info pages. There are a lot of possibilities here, go nuts.

There is a SCSS file included for dealing with some dimension variables of the device and some other variables.

The 3D phone includes a technique for the rounded corners involving pseudo elements for the sides, first implemented by brilliant web designer and developer Jonathan Levaillant.

source: http://tympanus.net/codrops/2013/08/01/3d-effect-for-mobile-app-showcase/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+tympanus+%28Codrops%29

Tuesday, July 30, 2013

Inspirational Website : 100ansdetour.fr


A beautifully designed hommage to celebrate 100 years of the Tour de France. Some great effects and a brilliant way to present data made us pick this website for this week's inspiration.

Tuesday, July 23, 2013

Tips Promoting Your Dev Skills


Many front-end developers possess the creative and technical skills that clients are looking for, but don’t get noticed because they don’t have much exposure or reputation to demonstrate to potential clients. Some carry the idea that their area of work is in such high demand that clients will simply come to them – but this is rarely the case.
A great way to get your name out there, build a reputation, and accumulate a list of clients is to market your specific skills. This is not only an excellent technique for freelancers, but it could also be what sets you apart from competition fighting for a particular job. As a developer, you may not know where to even begin in the process of marketing yourself. Follow these tips to increase your chances of attracting clients by effectively portraying your strengths.

1. Find Your Niche

It’s tempting to spread yourself thin and learn a little bit of everything so you can say that you can do it all, but you’ll benefit more by becoming an expert in one niche (you can’t be everything to everyone, after all). Narrow your interests or skills to something like ecommerce, blog, or mobile app design. Become an expert by learning the ins and outs of that area, and then working and experimenting with it. You’ll begin to build the groundwork of a good portfolio, and it will make reaching potential clients a less daunting endeavor. Your leadership in a specific field will increase your demand, leading to a flow of work that allows you to choose the best projects for you.

2. Get Published

As a way to help establish your expertise, consider writing an article or case study about your niche skill set. You can start by posting helpful articles on your blog or website to interest readers, and then start submitting longer pieces to other reputable sites like SmashingMagazine or e-book publishing networks. Even publishing a book as HTML on your site, like Addy Osmani does, can do wonders for your reputation. The community awards valuable resources with its full attention. This can result in invitations for speaking at conferences, networking with other community members and consultancy work.

3. Participate In Online Communities

You can also build your reputation by investing in communities like Stackoverflow and Quora. Not only does it allow you to connect with other developers, but it also publicly showcases your ability to solve problems. And through open source software platforms like Github, you can publish your projects and invite a host of other community collaborators. Having a strong foundation within these communities can be invaluable when communicating your expertise and building your network.

4. Create A Microsite

Single page websites are the perfect platform to show off your skills. Especially if you design one that focuses on a not-for-profit purpose that is creative, beautifully designed and contains interesting content. These are the sites that are more likely to be shared by users, which is a great way of getting free and quick exposure. Don’t be afraid to go crazy with features like parallax scrolling, unconventional grids and sliding effects to adequately showcase your abilities. On the flip side though, while it’s important to showcase the breadth of your skills, often time’s simple pages, like this iPod visualization or this one, can go a long way. This is a great way to let potential clients (or your interviewer) not simply look at, but interact with something you’ve created.
This home security guide for SimpliSafe, chock full of creativity and quality content, is a great example of a project that you can have people interact with. This one takes the user through the process of securing a home, enhanced with a clever comparison to a castle defense system and imaginative parallax scrolling.

5. Develop An Online Tool

If you’ve ever found yourself wishing there was a tool to serve a specific purpose to aid you in your work, consider making one yourself. Patrons will surely be amazed by the fact that you have developed a tool or app that other developers use. Sometimes the simplest concepts can be the most helpful, so simplify your ideas to make them look effortless.
CodePen is an example of how online tools can be immensely helpful to front-end developers. Use this in-browser code editor as inspiration for the tools you create.

6. Create Free Resources or Plugins

Another effective direction to gear your personal projects is to create free, downloadable resources for developers through the web. Consider enabling users to give feedback on their performance, so you can show clients that you’re dedicated to following through and improving on your projects. You can even submit them to sites like Design Instruct to gain more published exposure.
This UI designer created a Sketching and Wireframing Kit to provide a convenient and useful resource for UI and wireframing elements to his readers. Easily accessed right from his website, he offers multiple download formats and an opportunity for user feedback.

7. Use Social Networking

Social networking is arguably the most efficient means of free advertising. Since it’s fueled by users and their online word-of-mouth, your name and work can easily spread, which is why this is a marketing strategy worth your time. You can use sites like Facebook, Twitter and Pinterest to contribute high quality posts to the public, and link them back to your blog, which should narrow its content to further fit your niche audience. Internet users and clients will likely expect you to have accounts on all these networking sites, but make it easier for them to check them out through social media links on your blog and/or website, writing pieces and all other marketing elements you create.

8. Connect All Your Work

By linking all of your work and media sites to each other and keeping all your content consistent, you transform yourself from a freelancer (or job applicant) to a brand, which is much easier to market. You’ll build a following of readers and clients that can give feedback and recommendations to others, while your client base continues to grow. The work that you have developed to show to potential clients will put you that much further ahead of your competition, and you can anticipate the demand for your work to multiply. So instead of waiting for clients to come to you, use these assertive strategies to reveal your skills.


 by Luke Clum (http://tutorialzine.com/2013/07/8-tips-for-promoting-your-dev-skills/)



Tuesday, July 16, 2013

Tutorial On Scroll Header Effects

DEMO     -     DOWNLOAD

Some inspiration for headers that animate when scrolling the page. 
You’ve surely seen those really cool on scroll effects for headers that have been around lately. One example is the header on the Riot Industries website by Phil Renaud which rotates in 3d on click and enlarges when scrolling down. Similar work has been done by Johnny Simpson where he explores Scroll Activated Fixed Header Animations. We’ve also created a Blueprint for an On-Scroll Animated Header to get you started.

The demo for the effects serves as inspiration only and we’ve used a technique that involves changing the state classes of the header which would of course be customized depending on which effect would like to be used. It’s important to understand that the states depend on each other, i.e. changing from class A to class B does something (using transitions) and going from A to C might not cause the desired effect. So the order matters in this example that tries to show all the effects on one page.
Also note that scrolling super fast might cause a jump from the beforementioned class A to class C which might not always look very fancy.
In the demo we use the fantastic jQuery Waypoints plugin by Caleb Troughton.
The header is composed of various parts for showcasing all the effects. It has a perspective wrapper, a front and a bottom (for the 3d rotation):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<header id="ha-header" class="ha-header ha-header-large">
    <div class="ha-header-perspective">
        <div class="ha-header-front">
            <h1><span>Header Effects</span></h1>
            <nav>
                <a>‹ Previous Demo</a>
                <a>Something</a>
                <a>Anything</a>
                <a>Back to the article</a>
            </nav>
        </div>
        <div class="ha-header-bottom">
            <nav>
                <a>Dalliance</a>
                <a>Inglenook</a>
                <a>Lagniappe</a>
                <a>Mellifluous</a>
                <a>Erstwhile</a>
                <a>Wafture</a>
                <a>Serendipity</a>
                <a>Love</a>
            </nav>
        </div>
    </div>
</header>
We add a special class to the sections which will trigger the class change:
1
2
3
<section class="ha-waypoint" data-animate-down="ha-header-small" data-animate-up="ha-header-large">
    <!-- ... -->
</section>
The data atrributes are used for setting the right classes depending on which direction we are scrolling. In our demo the animate-up data attribute contains the class of the previous animate-down one.
An example for a state class is the following “rotate” one:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
.ha-header-rotate {
    height: 220px;
    top: 50px;
    padding-left: 50px;
    padding-right: 50px;
}
.ha-header-rotate .ha-header-front {
    transform: translateY(-100%) rotateX(90deg);
}
.ha-header-rotate .ha-header-bottom {
    top: 50%;
    transition: transform 0.5s;
    transform: rotateX(0deg) translateY(-100%);
}
The state classes are applied to the header element and from there we can define some changes for the children.

With the help of the Waypoints plugin we simply add the respective classes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var $head = $( '#ha-header' );
$( '.ha-waypoint' ).each( function(i) {
    var $el = $( this ),
        animClassDown = $el.data( 'animateDown' ),
        animClassUp = $el.data( 'animateUp' );
    $el.waypoint( function( direction ) {
        if( direction === 'down' && animClassDown ) {
            $head.attr('class', 'ha-header ' + animClassDown);
        }
        else if( direction === 'up' && animClassUp ){
            $head.attr('class', 'ha-header ' + animClassUp);
        }
    }, { offset: '100%' } );
} );
We hope you enjoy the effects and that they give you some inspiration on how to make a fancy animated header.

by: Mary Lou (Manoela Ilic)
source: http://tympanus.net/codrops/2013/07/16/on-scroll-header-effects/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+tympanus+%28Codrops%29



Advertisements

Advertisements