Page Loading Effects

A set of creative page loading effects that use SVG animations with Snap.svg. The idea is to show an overlay with a interesting shape animation while new content gets loaded.

PageLoadingEffects

View demo Download source

If you have visited the brilliantly designed websites of Nicolas Zezuka and Active Theory you might have noticed the slick loading animations that happen before new content is displayed. This kind of loading style is quite trendy lately and we wanted to give you some inspiration. The idea is to animate a shape into the viewport and show an activity indicator. When the new content is loaded, the shape will animate back to reveal the page. We’ll use animated SVGs with Snap.svg for the effects because this allows us to create complex shapes and interesting morphing transitions.

Please also note that the examples only serve for your inspiration. We haven’t implemented any fallbacks and we “fake” the dynamic loading of new content. Also note that we are animating SVGs and pseudo-elements which might not work well in some browsers.

The way we show the loading overlay is by defining an animation on a path that we define in the following SVG:

<div id="loader" class="pageload-overlay" data-opening="M 0,0 80,-10 80,60 0,70 0,0" data-closing="M 0,-10 80,-20 80,-10 0,0 0,-10">
	<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 80 60" preserveAspectRatio="none">
		<path d="M 0,70 80,60 80,80 0,80 0,70"/>
	</svg>
</div><!-- /pageload-overlay -->

We define an initial path that is not visible in the viewport inside of the SVG and a opening and closing path in data attributes on the pageload-overlay division. As you can see, we are using a small viewBox but we stretch the drawing to 100% of the window width and height while not preserving the aspect ratio. If we don’t have a closing path defined, we’ll animate back to the intial path.

Note that we can also add more than one path (separated by a semicolon) which allows for a step wise animation of the SVG drawing like you can see in the first demo.

We set the overlay division to a fixed position, covering all the page, and use a CSS-only loading indicator by styling the ::before and ::after pseudo elements of the division.

.pageload-overlay {
	position: fixed;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	visibility: hidden;
}

.pageload-overlay.show {
	visibility: visible;
}

.pageload-overlay svg {
	position: absolute;
	top: 0;
	left: 0;
}

.pageload-overlay svg path {
	fill: #fff;
}

We use visibility here because using those fixed positioning styles with pointer-events none on the SVG itself causes some trouble on mobile, so we position and manipulate the parent div instead.

You might have noticed that the circle animations is also done by animating from one path to another (there are of course other ways of doing this, scaling for example) but we used the following values to make sure the circle is “responsive” but does not stretch like the other shapes:

width="100%" height="100%" viewBox="0 0 80 60" preserveAspectRatio="xMidYMid slice"	

Using slice will preserve the aspect ratio but scale the drawing so that the entire viewport is covered by the viewBox.

We’ve only created a bunch of effects, but as you can see, the possibilities are endless.

We really hope you enjoy them and find them inspiring.

The featured image was created with this iMac/Macbook PSD mockup from Pixeden

View demo Download source

Previous:
Next:

Tagged with:

Mary Lou (Manoela Ilic) is a freelance web designer and developer with a passion for interaction design. She studied Cognitive Science and Computational Logic and has a weakness for the smell of freshly ground peppercorns.

View all contributions by

Website: http://tympanus.net/

Related Articles

Feedback 78

  1. 2

    Hi,
    I’m Designing a Loader:
    http://codepen.io/MHM5000/full
    How can I move a light throw it, instead of turn it on and off?
    Like the old Adobe/Macromedia Flash and it’s Masks??
    and more importantly, will it be something with simple css, js or it requires Canvas?

  2. 3

    Why I can’t use more than 2 page id’s on single html? Even when I link them it swtiches between those 2 first. Thanks for reply.

  3. 4

    how to do this effect on page load instead of click event, please tell , it is not happening

    • 6

      Morten has showed a good example few comments below.
      In the function replace
      // after some time hide loader
      setTimeout( function() {
      loader.hide();

      classie.removeClass( pages[ currentPage ], 'show' );
      // update..
      currentPage = currentPage ? 0 : 1;
      classie.addClass( pages[ currentPage ], 'show' );

      }, 2000 );

      With this

      // after some time hide loader
      setTimeout( function() {
      loader.hide();
      document.getElementByClass('container').style.display = 'none'
      }, 2000 );
      setTimeout( function() {
      document.location.href = trigger.getAttribute('href')
      }, 2000);

  4. 10

    Hello,

    Very awesome animated svg effect. I have been playing around a bit with it. I’m no jQuery mastermind, but I tried to link the animation to another page. On the clicked page it works just fine, but then on the page it goes to it doesn’t animate when opening. It like it lags the animation on the page it goes to. It shows some, but then just shows all instead of animating into the page.

    I have made a demo here where you can see what I’m talking about.

    my demo page

    Does anyone have an idea of how to fix it? I tried out some of Valerios code for the script itself, but still doesn’t function that well :S

    Any help would be much appreciated.

    • 11

      Ok seems like I got it to function now. But I don’t understand why the ms was the cause of it. I think it has something to do with the loading time of the page, but I’m not really sure.

      But my script ended up looking like this:

      (function() {
      var pageWrap = document.getElementById( 'pagewrap' ),
      pages = [].slice.call( pageWrap.querySelectorAll( 'div.container' ) ),
      currentPage = 0,
      triggerLoading = [].slice.call( pageWrap.querySelectorAll( 'a.pageload-link' ) ),
      loader = new SVGLoader( document.getElementById( 'loader' ), { speedIn : 100 } );

      function init() {
      triggerLoading.forEach( function( trigger ) {
      trigger.addEventListener( 'click', function( ev ) {
      ev.preventDefault();
      loader.show();
      // after some time hide loader
      setTimeout( function() {
      loader.hide();
      document.getElementByClass('container').style.display = 'none'
      }, 2000 );
      setTimeout( function() {
      document.location.href = trigger.getAttribute('href')
      }, 2500);
      } );
      } );
      }

      init();
      })();

      </code

    • 12

      Morten, cheers for sharing. I found your tweak very helpfull.

      Obviosly, awesome loading effects!!

  5. 15

    Hey guys,
    i try use this svg loader in my site but i don’t understand how use it!!!
    I want use a loader when the user do click in a link and the browser load the new page, i don’t want use this for load other divs in the same page.

    Please, can anyone help me?

  6. 16

    Hello again,

    I have noticed that when I in the browser use ‘go back one page’ then the loading stops on the page it going back to. Like it freezes.

    You can have a look at what I’m talking about here: my current demo

    Click any of the works and then click the browser button “go back one page”. Do you know what the problem for this could be?

    • 17

      Does anyone have a clue to why it freezes/locks itself once you’re in a project and click the browsers “Go back one page” button?

      Seems very odd to me, but not sure how to fix it.

  7. 18

    hi, can that loader use if i reload my page, so i don’t have to click some button to do that, thank you

    • 20

      no, i not find anything , once a try that loader is show after page finished load not point in time..

  8. 22

    Hello everyone again,

    I did find a semi-solution for the ‘Go back one page’. It’s obviously not what I really wanted, but it works and stops the freezing of the loading animation.

    To your tag add this ” onunload=” “, should look like this:

    That stops the freezing of the page animation. Soon I’ll launch my page. Where you can see what else I have used by the amazing tutorials in this forum. I hope you’ll enjoy it one I launch it, because it’s been a struggle. Hehe :)

    But enjoy.

    • 23

      Sorry I forgot code tags. So here:

      To your body tag add this ” onunload=” “, should look like this:


      <body onunload=''>

  9. 24

    Is there any way to allow this script to load multiple ID areas on one page, for example, I want an about, services and contact are, i’ve got 3 divs with different ID’s with 3 menu items pointing to said href ID’s but it only ever loads to the next one in line? Can anyone help at all? Cheers!

  10. 25

    How to make this auto loading when my page first load and then close when all the request from the server are loaded?

  11. 26

    Hi there,

    I try to use Windscreen wiper effect but the only thing that works is the preloader gif. between the 2 pages. Have you any idea why I can’t see the effect?

    Thanks for your time!

  12. 27

    Hi,

    Recently I found the Page Loading Effects and I try to use Windscreen Wiper in one of my creations but something seems to go wrong. I don’t see the actualy effect like the turning the leaves of a book. I see only the preloader gif.

    Have you any ideas why this happening?

    Thanks for your time!

  13. 28

    Great effect.

    Is there a way to initially start out with the loader present on a page and then reveal the page by hiding the loader?

    Thanks.

Follow this discussion

Leave a Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>