• Feed RSS
Showing posts with label Slideshow. Show all posts
Showing posts with label Slideshow. Show all posts

Supersized 3.2 – Fullscreen Slideshow jQuery Plugin

"

Introducing Supersized 3.2


Features

  • Resizes images to fill browser while maintaining image dimension ratio
  • Cycles backgrounds via slideshow with transitions and dynamic preloading
  • Core version is available for those that just want background resizing.
  • Navigation controls with keyboard support
  • Integration with Flickr – pull photos by user, set, or group
  • Head over to the project page for all the details.

New in Supersized 3.2

  • Complete rewrite of the Supersized script.
  • More options, including ability to prevent slides from being cut off.
  • Link directly to slides
  • API lets you call functions directly (eg. play/pause, next, previous, and jump directly to a slide)
  • Theme files are now separate from base files, which will make upgrades much easier. The Shutter theme is included in each download.
  • Flickr is not yet updated to 3.2 (it’s on it’s way)

Inspiration / Sites Using Supersized

I’ve put together a small sample of Supersized sites that I’ve come across recently. Keep in mind, these sites are not necessarily running the latest version, and some are heavily customized. I will be putting together a more extensive list for the project page, so feel free to shoot your site to sam@onemightyroar.com!

Plans for WordPress

I’ve noticed quite a few WordPress themes based on Supersized floating around – I plan on entering into the ring with an official Supersized WordPress theme. While I’m still at the early stages at this point, in the meantime, you should check out WP Supersized developed by the talented Ben De Boeck from World In My Eyes. Note: This plugin is currently using version 3.1.3

Comments and Feedback

Just a reminder, you can follow Supersized on Github, which is were I will publish minor point releases and field any bug reports.
If you have an urgent problem and/or would like to contact me directly to hire for custom work, please email me at sam@onemightyroar.com. For troubleshooting, make sure you have first checked the documentation and FAQ sections on the project page.
Enjoyed this project? Have a look at our Build Internet Projects page for some other stuff you make fancy as well.
Banner image provided by Colin Wojno. Other photography by Brooke Shaden and Maria Kazvan.
"
read more

How to Create a Slideshow Plugin with jQuery

How to Create a Slideshow Plugin with jQuery: "
There are hundreds of slideshow plugins out there, from all time favorites like Lightbox to the most advanced like Galleria. You might think, why make another one?. Well, most of us are using plugins like these on our websites, so why not use our own?
How to Create a Slideshow Plugin with jQuery

Introduction

If you use slideshow plugins frequently you may realize that there are basically two different types, the ones that slide and the ones with effects that don't slide. Choosing one or the other depends on the approach you take when coding it.
In this tutorial I'll discuss the creation process of Powerslide, a plugin I just released that follows the “effects” approach. You should have a basic knowledge of HTML, CSS and jQuery to follow this tutorial.

Project Setup

I suggest you download this project setup template. It'll be easier than having to create all the files and link them. It has all you need to get started with this tutorial. If you decide to use your own project template keep in mind that the relative paths might change.
This is how the project template looks:
Setup
960gs and modernizr are not necessary but they're really useful. We're not going to use a separate IE stylesheet but you might need it if you want to mess with IE later.

The Structure

We're going to start with the bare bones of the slider.
First, let's set the base HTML for the slideshow in index.html:
<div id="slider">
 <img src="img/img1.jpg" title="caption" />
 <img src="img/img2.jpg" title="caption" />
 <img src="img/img3.jpg" title="caption" />
</div>
Let's also call the jQuery plugin on document load in js/scripts.js:
$(function(){
 $('#slider').powerSlide();
});
Now, we have everything we need to start coding the plugin.
Let's take a look at the structure we want to achieve:
Structure
The following code serves only as preview. This is what we will be generating with jQuery.
<div class="powerSlide">
 <div class="wrapper">
  <a href="" class="prev"></a>
  <a href="" class="next"></a>
  <div class="image">
   <img src="" alt="" />
   <p></p>
  </div>
 </div>
 <div class="nav"></div>
</div>
We need to generate all these elements in the DOM from the original HTML. So, let's begin with a basic jQuery plugin template.
Open js/powerSlide.js.
(function($){
 $.fn.powerSlide = function(options { 

  var opt = {
   // Options
  };

  return this.each(function() {
   if (options) {
    $.extend(opt, options);
   }
   /* Code goes here */
  });
 };
})(jQuery);
Options are the variables that we can specify when calling the plugin on an element. These are the options we want to be able to change with their default values.
'width': 908, // Width and height of the images
'height': 340,
'position': 'bottom', // Position of the navigation
'bullets': false, // Show numbering navigation
'thumbs':  true, // Show thumbnail navigation
'row': 10, // Thumbnails per row
'auto': true, // Auto rotate
'autoSpeed': 4000,
'fadeSpeed': 1000
Now we can use the options with opt.option. For example, to use the width value we would write opt.width.
Inside the “each loop” and with the structure already in mind, we need to create the elements and assign them to variables so it's easier to refer to them later. Using firebug or the webkit developer tools we can track the elements as they're being created in the DOM.
/* Container and wrapper
-----------------------------------------------*/
$(this).children().wrapAll('<div class="powerSlide" />');
var container = $(this).find('.powerSlide');
container.find('img').wrapAll('<div class="wrapper" />');
var wrapper = container.find('.wrapper');

/* Previous & next buttons
-----------------------------------------------*/
wrapper.append('<a href="#" class="prev">Prev</a><a href="#" class="next">Next</a>');

/* Navigation & captions
-----------------------------------------------*/
switch (opt.position) { // Navigation position
  case 'top': container.prepend('<div class="nav" />'); break;
  case 'bottom': container.append('<div class="nav" />'); break;
}

var nav = container.find('.nav');

wrapper.find('img').each(function(i){

 i += 1; // Start numbers at 1

 if (opt.bullets === true) { // Bullet navigation
   nav.append('<a href="#">'+ i +'</a>');
 }

 if (opt.thumbs === true) { // Thumbnail navigation
   nav.addClass('thumbs').append(
    '<img class="thumb" src="'+
    $(this).attr('src') +'" alt=""/>');
 }

 // Captions
 var title = $(this).attr('title');
 $(this).wrapAll('<div class="image" />');
 if (title !== undefined) {
   $(this).attr('title', '');
   $(this).after('<p>'+ title +'</p>');
 }
});
You can now try changing the plugin options values to test different situations. Once the elements are created we can dive into the css.
This is just for the layout, but we will create a separate theme file for all the color customization and CSS3 goodness. This will help to keep the code clean and it'll be easier to create new themes later on.
Let's open css/powerSlide.css.
/* Wrapper
-------------------------------------------*/
.powerSlide .wrapper {
 overflow: hidden;
 padding: 15px;
 position: relative;
}

/* Image
-------------------------------------------*/
.powerSlide .wrapper img {
 position: absolute; /* They key to the “effects” approach */
}

/* Prev & Next buttons
-------------------------------------------*/
.powerSlide a.prev,
.powerSlide a.next {
 display: none;
 margin-top: -1em; /* Same as padding-top */
 padding: 1em 2em;
 position: absolute;
 text-decoration: none;
 top: 50%;
}
.powerSlide a.next {
 right: 0;
}

/* Caption
-------------------------------------------*/
.powerSlide .wrapper p {
 bottom: 0;
 display: none;
 padding: 1.5em;
 position: absolute;
}

/* Navigation
-------------------------------------------*/
.powerSlide .nav {
 margin: .5em 0;
 overflow: hidden;
}
.powerSlide .nav.thumbs {
 padding: 15px; /* Same as wrapper padding */
}
.powerSlide .nav img.thumb {
 cursor: pointer;
 float: left;
 margin: 2px;
 position: relative;
}
.powerSlide .nav img.thumb.current { /* Current thumbnail */
 z-index: 999;
}
.powerSlide .nav a {
 float:left;
 margin: .2em;
 min-width: 1em;
 padding: .2em .7em;
 text-align: center;
 text-decoration: none;
}
.powerSlide .nav a.current {} /* Current bullet */
As you can see the CSS is pretty straightforward. Elements that are inside the container have to be absolute positioned. Also be careful with margins and padding. We will generate the dimensions later on with jQuery.

The Slider Object

To store all the information and actions of the slider we're going to use an object. The most important concept of a slider is the index. We need to know the index of any given image at any time. The index will allow us to have control over which image needs to be shown when we trigger an event.
Here's a list of all the variables and a short description of what each one does.
  • imgs: the selector for all images.
  • imgCount: the number of images in the selection.
  • navNext: the next button.
  • navPrev: the previous button.
  • bullets: selector for all bullets in numbered navigation.
  • thumbs: selector for all thumbnails in thumbnail navigation.
  • captions: selector for all captions.
  • getCurrentIndex(): get the index of the current image at any given time.
  • go(index): go to an image of any given index.
  • next(): go to the next image.
  • prev(): go to the previous image.
  • init(): set width and height of the slideshow and calculte dimensions of dynamic elements.
/* Slider Object
-----------------------------------------------*/
var Slider = function(){

this.imgs = wrapper.find('div.image');
this.imgCount = (this.imgs.length) - 1; // Match index
this.navPrev = wrapper.find('a.prev');
this.navNext = wrapper.find('a.next');
this.bullets = container.find('.nav a');
this.thumbs = container.find('.nav img.thumb');
this.captions = this.imgs.find('p');

this.getCurrentIndex = function(){ // Index
 return this.imgs.filter('.current').index();
};

this.go = function(index){ // Rotate images
 this.imgs
  .removeClass('current')
  .fadeOut(opt.fadeSpeed)
  .eq(index)
  .fadeIn(opt.fadeSpeed)
  .addClass('current');
 this.bullets
  .removeClass('current')
  .eq(index)
  .addClass('current');
 this.thumbs
  .removeClass('current')
  .eq(index)
  .addClass('current');
};

this.next = function(){
 var index = this.getCurrentIndex();
 if (index < this.imgCount) {
  this.go(index + 1); // Go next
 } else {
  this.go(0); // If last go first
 }
};

this.prev = function(){
 var index = this.getCurrentIndex();
 if (index > 0) {
  this.go(index - 1); // Go previous
 } else {
  this.go(this.imgCount); // If first go last
 }
}; 

this.init = function(){ // Init
 wrapper
  .width(opt.width)
  .height(opt.height); /* Set width and height */

 this.imgs.hide().first().addClass('current').show(); /* Set current image */
 this.bullets.first().addClass('current');
 this.thumbs.first().addClass('current');

 // Dimensions for thumbnails and captions
 var padding = wrapper.css('padding-left').replace('px', '');
 var captionsPadding = this.captions.css('padding-left').replace('px', '');
 nav.width(opt.width);
 if (opt.thumbs === true) { // thumbs
  var thumbBorder = this.thumbs.css('border-left-width').replace('px', '');
  var thumbMargin = this.thumbs.css('margin-right').replace('px', '');
  var thumbMaxWidth = opt.width/opt.row;
  this.thumbs.width( (thumbMaxWidth - (thumbMargin * 2)) - (thumbBorder * 2) );
 }
 this.captions // captions
  .width(opt.width - (captionsPadding * 2) + 'px')
  .css('margin-bottom', padding + 'px');
 this.navNext.css('margin-right', padding + 'px');
   };

};
Now that the object is defined we have to create a new instance and load it with the init() function.
var slider = new Slider();
slider.init();

Events

Mouse Events

We want to trigger the following events:
  • Click next and go to next image
  • Click prev and go to previous image
  • Click on a numbered bullet and go to that image
  • Click on thumbnail and go to that image
  • Hover image and show caption and buttons
We have to disable the default behavior of the link items with e.preventDefault() to avoid jumping to the top of the page when clicking on empty links.
Also make sure you hide the captions when not hovering over the image. I think the code for this part could be DRYer but it's good for readability.
wrapper.hover(function(){ // Hover image wrapper
 slider.captions.stop(true, true).fadeToggle();
 slider.navNext.stop(true, true).fadeToggle();
 slider.navPrev.stop(true, true).fadeToggle();
});
slider.navNext.click(function(e){ // Click next button
 e.preventDefault();
 slider.next();
});
slider.navPrev.click(function(e){ // Click previous button
 e.preventDefault();
 slider.prev();
});
slider.bullets.click(function(e){  // Click numbered bullet
 e.preventDefault(); slider.captions.hide();
 slider.go($(this).index());
});
slider.thumbs.click(function(){ // Click thumbnail
 slider.captions.hide();
 slider.go($(this).index());
});

Auto Rotate Images

This part is kind of boring, just make sure the caption is hidden when not hovering over the image.
if (opt.auto === true) {
 var timer = function(){
   slider.next();
   slider.captions.hide();
 };
 var interval = setInterval(timer, opt.autoSpeed);

 // Pause when hovering image
 wrapper.hover(function(){clearInterval(interval);}, function(){interval=setInterval(timer, opt.autoSpeed);});

 // Reset timer when clicking thumbnail or bullet
 slider.thumbs.click(function(){clearInterval(interval); interval=setInterval(timer, opt.autoSpeed);});
 slider.bullets.click(function(){clearInterval(interval); interval=setInterval(timer, opt.autoSpeed);});
}

Creating a Theme

Everything should be working at this point. Let's make it pretty then.
Create the file css/powerSlide_theme.css and include it in index.html.
<link href="css/powerSlide_theme.css" rel="stylesheet" type="text/css" media="screen"/>
And with the help of Colorzilla CSS3 gradient generator let's add some styles.
/* Wrapper
-------------------------------------------*/
.powerSlide .wrapper {
 background:#fff;
 border:1px solid #999;
}

/* Prev & Next buttons
-------------------------------------------*/
.powerSlide a.prev,
.powerSlide a.next {
 background:#fff;
 box-shadow:2px 0 2px rgba(0,0,0,.3);
 color:#000;
 font:bold 10px Arial;
}
.powerSlide a.next {
 box-shadow:-2px 0 2px rgba(0,0,0,.3);
}

/* Caption
-------------------------------------------*/
.powerSlide .wrapper p {
 background:#000;
 background:rgba(0,0,0,.7);
 color:#fff;
}

/* Navigation
-------------------------------------------*/
.powerSlide .nav.thumbs {
 background:#b5bdc8;
 border:1px solid #999;
}
.powerSlide .nav img.thumb {
margin: 3px;
 box-shadow:0 0 2px #666;
 border: 4px solid transparent;
 filter:alpha(opacity=40);
 opacity:.4;
}
.powerSlide .nav a {
 background:#7d7e7d;
 background:-moz-linear-gradient(top, #7d7e7d 0%, #0e0e0e 100%);
 background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#7d7e7d), color-stop(100%,#0e0e0e));
 background:-webkit-linear-gradient(top,#7d7e7d0%,#0e0e0e100%);
 background:-o-linear-gradient(top,#7d7e7d0%,#0e0e0e100%);
 background:-ms-linear-gradient(top,#7d7e7d0%,#0e0e0e100%);
 background:linear-gradient(top,#7d7e7d0%,#0e0e0e100%);
 border-radius:3px;
 color:#fff;
 filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#7d7e7d',endColorstr='#0e0e0e',GradientType=0);
 font:bold 12px Arial;
}
.powerSlide .nav img.thumb.current {
 box-shadow:0 0 10px #fff;
 border: 4px solid #fff;
 filter:alpha(opacity=100);
 opacity:1;
}
.powerSlide .nav a.current {
 background:#1e5799;
 background:-moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%);
 background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8));
 background:-webkit-linear-gradient(top,#1e57990%,#2989d850%,#207cca51%,#7db9e8100%);
 background:-o-linear-gradient(top,#1e57990%,#2989d850%,#207cca51%,#7db9e8100%);
 background:-ms-linear-gradient(top,#1e57990%,#2989d850%,#207cca51%,#7db9e8100%);
 background:linear-gradient(top,#1e57990%,#2989d850%,#207cca51%,#7db9e8100%);
 filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1E5799',endColorstr='#7db9e8',GradientType=0);
}

Notes

The plugin works in IE7+ and all other modern browsers. For some reason, even in IE9, the images don't fade. This problem must be related to the fadeIn and fadeOut jQuery functions.
Bullets and thumbnails can't be displayed at the same time but who wants to have them both anyway?
I will be glad to answer any questions. I encourage you to create your own theme and post it here. It'll be great to have a community theme repository.

Written by: Cedric Ruiz
"
read more

Build a Pure CSS Slideshow With Webkit Keyframes

Build a Pure CSS Slideshow With Webkit Keyframes: "
While playing around with Webkit Keyframe Animations I figured out a way to create an awesome little image slider using only CSS. It’s definitely a bit unconventional but it’s a great way to learn to think outside of the box with what you can do with CSS3.

Keep in mind that since we’re using Webkit Keyframes, this is purely an educational experiment and will only work in Safari or Chrome. As more browsers begin to support keyframe animations in the future, this method should become perfectly usable in your own web projects.



Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter to stay up on recent content.

What We’re Building


Slideshow Live Demo: Click here

screenshot

Porthole Live Demo: Click here

screenshot

Why Pure CSS?


Before anyone gets too excited, I want to recognize that, at this point in time, this is a job for JavaScript. Though some rare and confused souls browse with JavaScript turned off, that will leave out a much lower percentage of your audience than today’s method.

That said, I think it’s important and even fun to experiment with upcoming technologies to see how we’ll be coding in the near future. As we saw in our recent article on creating Colorful Pulsing Backgrounds, Webkit Keyframe Animations really stretch what’s possible with CSS and are actually quite easy to work with.

Getting Started: Basic HTML


To begin, let’s create the page as if it contained only static elements. We’re not going to worry too much about creating a complex page design this time around, just a simple container with the slideshow and a headline.

With that in mind, the markup for this project is super simple:

<div id='container'> <div id='headline'> <h1>Webkit Slideshow</h1> <p>An image slider made with pure CSS.</p> </div>
<div id='slideshow'> </div>
</div>

</ br>

After this, you shouldn’t have anything more than a white page with some text on it:

screenshot

Basic CSS


Now that we have our markup all laid out, it’s time to start styling the page to make it look presentable. The first thing I’m going to do is throw in a basic margin/padding reset, apply a background to the body and center the container.

The reset simply helps clear any browser presets and centering the div is as easy as applying a width and setting the left and right margins to auto.

* { margin: 0; padding: 0;
}

body { background: url(black_denim.jpg); /* source: http://subtlepatterns.com/ */
}

#container { width: 960px; margin: 0 auto;
}

</ br>

Styling the Text


Now that our background and container are set up, let’s make the headline look a little better. Our markup created three sections to work with: the headline div, the h1 and the paragraph.

I started by applying some margins to the entire div along with centering any text within and setting the default color to white. After this I applied some basic font styling (using shorthand) to the h1 and paragraph tags.

#headline { margin: 50px 0 30px 0; text-align: center; color: #fff;
}

#headline h1 { font: 60px/55px 'Josefin Sans', Helvetica, sans-serif; font-weight: normal; color: #37c5fb;
}

#headline p { font: 20px/25px 'Josefin Sans', Helvetica, sans-serif;
}

</ br>

Note that I’ve used ‘Josefin Sans’ for the font. This is from the Google Font Library so to make it work make sure you have this snippet in the head section of your HTML.

<link href='http://fonts.googleapis.com/css?family=Josefin+Sans' rel='stylesheet' type='text/css'>

</ br>

And with that, our page is starting to look a lot nicer!

screenshot

Styling the Image


Now we need to apply a background to the slideshow div. In the next step we’ll do a lot more with this but for now you basically just want to choose a placeholder image and apply a width and height to the div.

#slideshow { width: 465px; height: 300px; background: url(slideshow-1.jpg); margin: 0 auto;
}

</ br>

Our page is looking great at this point. Now that we’ve got it how we want, we can proceed with bringing it to life!

screenshot

Setting Up the Slideshow Image


The way that we’ll be setting up this slideshow is basically through the use of a modified version of CSS sprites. The idea is to create one big image containing all of our slides then to use keyframe animations to reveal specific portions of the image at certain points in the animation.

If that doesn’t quite make sense yet, don’t worry, it’s a lot easier than you think! To start off, we’ll need to go into Photoshop and build our image. Now, given that the size we set up above for the slideshow is 465px wide by 300px tall, we’ll need to make our Photoshop document 930px by 600px (double both the width and the height). This will give us enough area for four images, if you want more, simply make it bigger!

From here, you want to drop in four images, each of which is 465px by 300px. Set them up in a grid with no gaps and save out a JPG at full size. Your result should look something like the image below.

screenshot

Slideshow CSS


Webkit Keyframe Animations are really simple to work with. All you have to so is choose something to animate and then set the state of that item at various points in the animation, defined by percentages. So if you set the width of a div to 100px at 0%, 50px at 50% and 10px at 100%, the div will shrink over the course of the animation.

Today, we’re going to animate the background-position property. Our slideshow is set up to show only the top left quadrant of our image by default and we can use background-position to move that around to show the others.

To visualize this, picture our webpage as a dark background with a rectangle hole cut in it. The image we just created is then set under that hole and we’re going to move it around.

First, we want to go from the top left picture to the top right picture, so we’re going to set the “right” value (the first number) to the negative width of one image (465px). Next, we set the “up” value (the second value) to the negative height of one image (300px). Finally, we stay at -300 on the height but bring the right value back to zero. The effect of this will be to show the top left image, the top right image, the bottom right image and then the bottom left image.

@-webkit-keyframes slider { 0% {background-position: 0px 0px} 10% {background-position: 0px 0px} 33% {background-position: -465px 0px} 66% {background-position: -465px -300px} 100% {background-position: 0px -300px}
}

</ br>

Notice that I threw a bit of a curve ball in here and set everything to 0 at 10%. This is because I didn’t like the slideshow starting right away without giving you a chance to look at the first image. This simply builds in a brief pause.

Also, one of the most important elements here is the syntax at the beginning: “@-webkit-keyframes slider”. The “@-webkit-keyframes” part tells the browser what you’re defining with the code below but the “slider” part is a customizable title that you give the animation. It can be anything you want, just remember to use it again in the next step when we activate this animation.

Activating the Slideshow


Throwing in the CSS above defines the behavior of the slideshow, but it doesn’t activate it. To do that, you need to add a new line into your slideshow div.

#slideshow { width: 465px; height: 300px; background: url(slideshow-1.jpg); margin: 0 auto;
/*Animation*/ -webkit-animation: slider 20s infinite alternate;
}

</ br>

Here I called the “slider” animation that we just defined, then set the length to 20 seconds, the iterations to infinite and the direction to alternate (once the animation is finished, it will go backwards to the beginning).

Demo


With that, we’re all finished! Check out the live demo to see it in action. Again, make sure you’re using Safari or Chrome.

screenshot

Alternative Execution: Porthole Effect


Notice that this technique isn’t really using multiple images but is instead just panning around a single image. Because of this, you can achieve a really cool effect by simply utilizing one large photo.

To see how this works, I grabbed an underwater image and modified the page above to have a sort of ocean porthole feel. The code is shown below. Notice that this time, instead of making the animation start automatically, it only takes place when the user hovers over the image.

For the styling, I simply rounded the corners of the div so that it’s a circle and applied a box shadow set to inset to give it that cut out look.

<div id='container'> <div id='headline'> <h1>Webkit Porthole</h1> <p>Hover over the image below to look around.</p> </div>
<div id='slideshow'> </div>
</div>

</ br>

* { margin: 0; padding: 0;
}

body { /*background: url(http://griddle.it/960-12-30) repeat-y center top;*/ background: url(black_denim.jpg);
}

#container { width: 960px; margin: 0 auto;
}

#headline { margin: 50px 0 30px 0; text-align: center; color: #fff;
}

#headline h1 { font: 60px/55px 'Josefin Sans', Helvetica, sans-serif; font-weight: normal; color: #37c5fb;
}

#headline p { font: 20px/25px 'Josefin Sans', Helvetica, sans-serif;
}

#slideshow { width: 300px; height: 300px; background: url(fish.jpg); margin: 0 auto; -webkit-border-radius: 150px; -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.9);

}

@-webkit-keyframes slider { 0% {background-position:0px 0px} 33% {background-position:0px -300px} 66% {background-position:-300px -300px} 100% {background-position:-300px 0px}
}


#slideshow:hover { -webkit-animation: slider 20s infinite alternate ease;
}

</ br>

Demo


To see the Porthole Demo, click on the image below.

screenshot

Conclusion


In summary, Webkit Keyframe Animations hold tons of potential for making web pages impressively dynamic without a shred of JavaScript. Typically this kind of effect would take a pretty decent chunk of code but with CSS it’s incredibly easy.

Leave a comment below and let us know what you think of the effect. Are you excited that CSS is expanding to include these types of behaviors or do you think that this should always be the job of JavaScript? Let us know!
"
read more

Sliding Letters with jQuery

Sliding Letters with jQuery: "

Today we have a neat little effect for you. We want to bring some life to the standard hover effect by playing around with the letters in an anchor word. The aim is to slide in letter by letter when hovering over a link element. We can either have the same word or a different one and we can slide in the new letters all the same time or one after the other.
We will be using the Lettering.js jQuery Plugin which you can find on Github.

Example

In the following we will go through an example and we’ll start by the html for a little menu:
<div class="sl_examples">
<a href="#" id="example1" data-hover="Creativity">Illustrations</a>
</div>
We will use data-hover to indicate the word that should appear on hover. If you don’t use the data-hover then the same word will be used on hover.
Then we will style it in the following way, making sure that we have the right properties for the structure that will be generated:
.sl_examples{
float:left;
font-family: 'Bevan', arial, serif;
font-size:50px;
line-height:50px;
color:#f0f0f0;
margin-right:5px;
text-transform:uppercase;
}
.sl_examples a{
display:block;
position:relative;
float:left;
clear:both;
color:#fff;
}
.sl_examples a > span{
height:50px;
float:left;
position:relative;
overflow:hidden;
}
.sl_examples a span span{
position:absolute;
display:block;
left:0px;
top:0px;
text-align:center;
}
.sl_examples a span span.sl-w1{
color:#fff;
text-shadow:0px 0px 1px #fff;
z-index:2;
}
.sl_examples a span span.sl-w2{
color:#e82760;
text-shadow:-1px 1px 2px #9f0633;
z-index:3;
}
So, “sl-w1″ is the class for the first word letters and “sl-w2″ is the class for the second word letters.
Finally, we call the plugin:
$(window).load(function(){
$('#example1').hoverwords({ delay:50 });
});
The following settings can be used:
delay  : false,  // each letter will have different animation times
speed  : 300,   // animation speed
easing  : 'jswing',  // easing animation
dir   : 'leftright',  // leftright - current goes left, new one goes right || rightleft - current goes right, new one goes left,
overlay  : false,  // hover word is slided on top of the current word (just for the case when the hover word equals word)
opacity  : true   // animate the letters opacity
We hope you liked this little experiment and find it useful!
View demoDownload source

"
read more

Slider Kit – Multiple Slideshow Types In One jQuery Plugin

Slider Kit – Multiple Slideshow Types In One jQuery Plugin: "
Slider Kit is a very flexible jQuery plugin that enables us to create almost any type of slideshows like photo galleries, news sliders, carousels and more.

It has support for both horizontal + vertical sliders and items can be navigated via buttons, mousewheel, image click or keyboard.

jQuery Slider Kit

There are lots of options provided like auto-start being on/off, animation types, navigation being an infinite loop or not, starting position of the slideshow and much more.

The complete skin of the slideshows can be customized with CSS and the plugin weights only ~8kb (minified).
"
read more

8 Unique Transition Effects Image Slider Using jQuery – AviaSlider

8 Unique Transition Effects Image Slider Using jQuery – AviaSlider: "
As we know jQuery is the best JavaScript library, we can do almost everything in Web. AviaSlider came up with one best 8 Unique Transition Effects image slider which is developed using jQuery. This 8 unique transition effects includes Diagonal Blocks Effect, Winding Blocks Effect, Randomized Blocks, Dropping Curtain, Fading Curtain, Fading Top Curtain, FullWidth Fade Slider, Direction Fade Slider. Its best features includes Image Preloader, Autoplay that stops on user interaction, Valid HTML5 and CSS 3 Markup, Packed version only weights 8kb, Supports linked images, works with jQuery 1.32 and higher, Lots of easy to set options to create your own effects.



It supports all major browsers and this Image Slider is successfully tested and works perfectly in Internet Explorer 6 and higher, Safari 3 and higher, Firefox 2 and higher, Opera 10 and higher, Google Chrome 3 and higher, Checks for last 3 Browsers performed on Mac & Win. You can get this Slider for $12 in Regular Licence and you can grab the same in Extended Licence at $60 from http://codecanyon.net – download

8 Unique Transition Effects Image Slider - AviaSlider

"
read more

Slides: Customizable and Stylish Slideshow Plugin for jQuery

Slides: Customizable and Stylish Slideshow Plugin for jQuery: "
Slides is a simple jQuery slideshow that is easy to implement, customize and style. It includes features like looping, auto play, fade or slide transition effects, crossfading, image preloading, auto generated pagination. Slides is compatible with all modern web browsers including; Internet Explorer 7/8/9, Firefox 3+, Chrome, Safari and Mobile Safari. It even works in the old IE6.
My favorite feature of Slides and main reason for its development is you never see multiple slides fly by. You get to the end and it loops. You click from slide 1 to 5 and slide 5 just slides in from the right. Awesome.
read more

Fancy Sliding Form with jQuery

Fancy Sliding Form with jQuery: "





View demoDownload source

Today we are going to create a fancy sliding form that shows some validation feedback to the user after each step. This form saves a lot of space and is easy to access – it basically works like a slide show, just that we have fieldsets of a form instead of images.

So let’s start!

The Markup


The HTML will consist of a wrapper container where we will place a form with fieldsets. Each fieldset will be a step in our sliding form:

<h1>Fancy Sliding Form with jQuery</h1>
<div id="wrapper">
<div id="steps">
<form id="formElem" name="formElem" action="" method="post">
<fieldset class="step">
<legend>Account</legend>
<p>
<label for="username">User name</label>
<input id="username" name="username" />
</p>
<p>
<label for="email">Email</label>
<input id="email" name="email" type="email" />
</p>
<p>
<label for="password">Password</label>
<input id="password" name="password" type="password" />
</p>
</fieldset>
<fieldset>
...
</fieldset>
</form>
</div>
<div id="navigation" style="display:none;">
<ul>
<li class="selected">
<a href="#">Account</a>
</li>
<li>
<a href="#">Personal Details</a>
</li>
<li>
<a href="#">Payment</a>
</li>
<li>
<a href="#">Settings</a>
</li>
<li>
<a href="#">Confirm</a>
</li>
</ul>
</div>
</div>

The navigation with all the links to the steps will be an unordered list that is initially hidden. We will show it in our JavaScript function.

Let’s look at the style.

The CSS


The main wrapper and the steps container will have the following style:

#wrapper{
-moz-box-shadow:0px 0px 3px #aaa;
-webkit-box-shadow:0px 0px 3px #aaa;
box-shadow:0px 0px 3px #aaa;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px;
border:2px solid #fff;
background-color:#f9f9f9;
width:600px;
overflow:hidden;
}
#steps{
width:600px;
overflow:hidden;
}
.step{
float:left;
width:600px;
}

The class step will be given to each fieldset. Let’s style the navigation:

#navigation{
height:45px;
background-color:#e9e9e9;
border-top:1px solid #fff;
-moz-border-radius:0px 0px 10px 10px;
-webkit-border-bottom-left-radius:10px;
-webkit-border-bottom-right-radius:10px;
border-bottom-left-radius:10px;
border-bottom-right-radius:10px;
}
#navigation ul{
list-style:none;
float:left;
margin-left:22px;
}
#navigation ul li{
float:left;
border-right:1px solid #ccc;
border-left:1px solid #ccc;
position:relative;
margin:0px 2px;
}

The single link elements will have a neat CSS3 gradient as background:

#navigation ul li a{
display:block;
height:45px;
background-color:#444;
color:#777;
outline:none;
font-weight:bold;
text-decoration:none;
line-height:45px;
padding:0px 20px;
border-right:1px solid #fff;
border-left:1px solid #fff;
background:#f0f0f0;
background:
-webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.09, rgb(240,240,240)),
color-stop(0.55, rgb(227,227,227)),
color-stop(0.78, rgb(240,240,240))
);
background:
-moz-linear-gradient(
center bottom,
rgb(240,240,240) 9%,
rgb(227,227,227) 55%,
rgb(240,240,240) 78%
)
}
#navigation ul li a:hover,
#navigation ul li.selected a{
background:#d8d8d8;
color:#666;
text-shadow:1px 1px 1px #fff;
}

When a step get’s validated, we will either add a span indicating that everything is fine, or a span that shows that something is wrong in the form step:

span.checked{
background:transparent url(../images/checked.png) no-repeat top left;
position:absolute;
top:0px;
left:1px;
width:20px;
height:20px;
}
span.error{
background:transparent url(../images/error.png) no-repeat top left;
position:absolute;
top:0px;
left:1px;
width:20px;
height:20px;
}

The styles for the form elements look as follows:

#steps form fieldset{
border:none;
padding-bottom:20px;
}
#steps form legend{
text-align:left;
background-color:#f0f0f0;
color:#666;
font-size:24px;
text-shadow:1px 1px 1px #fff;
font-weight:bold;
float:left;
width:590px;
padding:5px 0px 5px 10px;
margin:10px 0px;
border-bottom:1px solid #fff;
border-top:1px solid #d9d9d9;
}
#steps form p{
float:left;
clear:both;
margin:5px 0px;
background-color:#f4f4f4;
border:1px solid #fff;
width:400px;
padding:10px;
margin-left:100px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow:0px 0px 3px #aaa;
-webkit-box-shadow:0px 0px 3px #aaa;
box-shadow:0px 0px 3px #aaa;
}
#steps form p label{
width:160px;
float:left;
text-align:right;
margin-right:15px;
line-height:26px;
color:#666;
text-shadow:1px 1px 1px #fff;
font-weight:bold;
}
#steps form input:not([type=radio]),
#steps form textarea,
#steps form select{
background: #ffffff;
border: 1px solid #ddd;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
outline: none;
padding: 5px;
width: 200px;
float:left;
}
#steps form input:focus{
-moz-box-shadow:0px 0px 3px #aaa;
-webkit-box-shadow:0px 0px 3px #aaa;
box-shadow:0px 0px 3px #aaa;
background-color:#FFFEEF;
}
#steps form p.submit{
background:none;
border:none;
-moz-box-shadow:none;
-webkit-box-shadow:none;
box-shadow:none;
}
#steps form button {
border:none;
outline:none;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
color: #ffffff;
display: block;
cursor:pointer;
margin: 0px auto;
clear:both;
padding: 7px 25px;
text-shadow: 0 1px 1px #777;
font-weight:bold;
font-family:'Century Gothic', Helvetica, sans-serif;
font-size:22px;
-moz-box-shadow:0px 0px 3px #aaa;
-webkit-box-shadow:0px 0px 3px #aaa;
box-shadow:0px 0px 3px #aaa;
background:#4797ED;
}
#steps form button:hover {
background:#d8d8d8;
color:#666;
text-shadow:1px 1px 1px #fff;
}

And now, let’s add some JavaScript magic!

The JavaScript


In our function we will first take care of the display of the slider. For that we need to calculate the width of the elements inside. We will also take care of the sliding when we tab through the inputs. When the user hits tab when he is in the last input of a fieldset, we make the next fieldset slide into place and focus on the first field.

The validation of the form is based on all inputs being required fields. If we slide to the next fieldset and did not fill out all the inputs of the previous one, we will mark the missing inputs with a red background and add our little error span to the navigation item. If everything was fine, we will add the span with the check mark so that the user knows, the step was correct. We will not allow the user to submit the form if one of the steps contains errors.

$(function() {
/*
number of fieldsets
*/
var fieldsetCount = $('#formElem').children().length;

/*
current position of fieldset / navigation link
*/
var current  = 1;

/*
sum and save the widths of each one of the fieldsets
set the final sum as the total width of the steps element
*/
var stepsWidth = 0;
var widths   = new Array();
$('#steps .step').each(function(i){
var $step   = $(this);
widths[i]    = stepsWidth;
stepsWidth   += $step.width();
});
$('#steps').width(stepsWidth);

/*
to avoid problems in IE, focus the first input of the form
*/
$('#formElem').children(':first').find(':input:first').focus(); 

/*
show the navigation bar
*/
$('#navigation').show();

/*
when clicking on a navigation link
the form slides to the corresponding fieldset
*/
$('#navigation a').bind('click',function(e){
var $this = $(this);
var prev = current;
$this.closest('ul').find('li').removeClass('selected');
$this.parent().addClass('selected');
/*
we store the position of the link
in the current variable
*/
current = $this.parent().index() + 1;
/*
animate / slide to the next or to the corresponding
fieldset. The order of the links in the navigation
is the order of the fieldsets.
Also, after sliding, we trigger the focus on the first
input element of the new fieldset
If we clicked on the last link (confirmation), then we validate
all the fieldsets, otherwise we validate the previous one
before the form slided
*/
$('#steps').stop().animate({
marginLeft: '-' + widths[current-1] + 'px'
},500,function(){
if(current == fieldsetCount)
validateSteps();
else
validateStep(prev);
$('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus();
});
e.preventDefault();
});

/*
clicking on the tab (on the last input of each fieldset), makes the form
slide to the next step
*/
$('#formElem > fieldset').each(function(){
var $fieldset = $(this);
$fieldset.children(':last').find(':input').keydown(function(e){
if (e.which == 9){
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
/* force the blur for validation */
$(this).blur();
e.preventDefault();
}
});
});

/*
validates errors on all the fieldsets
records if the form has errors in $('#formElem').data()
*/
function validateSteps(){
var FormErrors = false;
for(var i = 1; i < fieldsetCount; ++i){
var error = validateStep(i);
if(error == -1)
FormErrors = true;
}
$('#formElem').data('errors',FormErrors);
}

/*
validates one fieldset
and returns -1 if errors found, or 1 if not
*/
function validateStep(step){
if(step == fieldsetCount) return;

var error = 1;
var hasError = false;
$('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input:not(button)').each(function(){
var $this   = $(this);
var valueLength = jQuery.trim($this.val()).length;

if(valueLength == ''){
hasError = true;
$this.css('background-color','#FFEDEF');
}
else
$this.css('background-color','#FFFFFF');
});
var $link = $('#navigation li:nth-child(' + parseInt(step) + ') a');
$link.parent().find('.error,.checked').remove();

var valclass = 'checked';
if(hasError){
error = -1;
valclass = 'error';
}
$('<span class="'+valclass+'"></span>').insertAfter($link);

return error;
}

/*
if there are errors don't allow the user to submit
*/
$('#registerButton').bind('click',function(){
if($('#formElem').data('errors')){
alert('Please correct the errors in the Form');
return false;
}
});
});

And that’s it! I hope you liked the sliding form idea!

View demoDownload source
"
read more