In our new tutorial I would like to show you how to create a nice looking photo gallery with transition effects. I’m going to use a ready jQuery plugin – jqFancyTransitions. It is easy and effective jQuery plugin to display photos as photo slideshow with fancy transition effects (wave, zipper and curtain). There are a lot of ways to customize the result. All the possible options will be published at the end of this article.
Ok, let’s download the source files and start coding !
Step 1. HTML
Firstly, in order to use this gallery we should add all the necessary styles and scripts in the header section:
2 | < link href = "css/main.css" rel = "stylesheet" type = "text/css" /> |
6 | < script src = "js/jqFancyTransitions.1.8.min.js" ></ script > |
7 | < script src = "js/main.js" ></ script > |
Then, we can prepare an easy html markup of our photo gallery with several photos:
2 | < img src = "images/pic1.jpg" alt="<i>A look to New Jersey < a href = 'http://1x.com/photo/53587' >by Hannes Cmarits</ a ></ i >" /> |
3 | < img src = "images/pic2.jpg" alt="<i>Reflections [color] < a href = 'http://1x.com/photo/20045' >by Sven Fennema</ a ></ i >" /> |
4 | < img src = "images/pic3.jpg" alt="<i>Silk < a href = 'http://1x.com/photo/45014' >by Bryan Jolly</ a ></ i >" /> |
5 | < img src = "images/pic4.jpg" alt="<i>Space City III < a href = 'http://1x.com/photo/31495' >by WisoNet</ a ></ i >" /> |
6 | < img src = "images/pic5.jpg" alt="<i>Forms and reflections < a href = 'http://1x.com/photo/30093' >by Sven Fennema</ a ></ i >" /> |
7 | < img src = "images/pic6.jpg" alt="<i>Skyarena < a href = 'http://1x.com/photo/19329' >by Luis Romero</ a ></ i >" /> |
There are six images, each of them has alt attribute, afterward, the value of this attribute will be converted into title for every photo, as you can see – we can use html entities here.
Step 2. CSS
css/main.css
In order to produce good result, I had to customize our gallery:
02 | background-color : rgba( 128 , 128 , 128 , 0.8 ) !important ; |
16 | -webkit-transition: all 0.2 s ease-in-out 0 s; |
17 | -moz-transition: all 0.2 s ease-in-out 0 s; |
18 | -o-transition: all 0.2 s ease-in-out 0 s; |
19 | -ms-transition: all 0.2 s ease-in-out 0 s; |
20 | transition: all 0.2 s ease-in-out 0 s; |
23 | background-color : rgba( 128 , 128 , 128 , 0.5 ); |
24 | border-color : transparent #0072BC transparent transparent ; |
25 | border-radius: 0 30px 30px 0 ; |
33 | background-color : rgba( 128 , 128 , 128 , 0.5 ); |
34 | border-color : transparent transparent transparent #0072BC ; |
35 | border-radius: 30px 0 0 30px ; |
43 | border-right-color : #00548b ; |
46 | border-left-color : #00548b ; |
48 | #ft-buttons-gallery a:link, #ft-buttons-gallery a:visited { |
49 | background-color : #F5F5F5 ; |
50 | border : 1px solid #EBEBEB ; |
55 | text-decoration : none ; |
58 | #ft-buttons-gallery a.ft-button-gallery-active { |
59 | background-color : #DDEEFF ; |
60 | border : 1px solid #BBDDFF ; |
65 | text-decoration : none ; |
There are styles for the customized title area, prev and next buttons and for pagination.
Step 3. JS
js/main.js
Now, we have to initialize our photo gallery:
js/main.js
02 | $( '#gallery' ).jqFancyTransitions({ |
12 | direction: 'fountainAlternate' , |
Everything is very easy, isn’t it? You can follow this link in order to find an official demonstration and documentation.
Step 4. Images
All the gallery images are in ‘images’ folder.
jqFancyTransitions params
You can use the next properties to ininialize this plugin:
Param | Type | Default | Description |
effect | string | | Transition effect, possible values are: wave, zipper and curtain |
width | int | 500 | Panel width |
height | int | 332 | Panel height |
strips | int | 10 | Strips amount |
delay | int | 5000 | Delay between images in ms |
stripDelay | int | 50 | Delay beetwen strips in ms |
titleOpacity | float | 0.7 | Title’s opacity |
titleSpeed | int | 1000 | Speed of title appereance in ms |
position | string | alternate | Strips position: top, bottom, alternate, curtain |
direction | string | fountainAlternate | Strips direction: left, right, alternate, random, fountain, fountainAlternate |
navigation | boolean | false | Display prev-next navigation buttons |
links | boolean | false | Display images as links |
Conclusion
That is all for today. We have just created new photo gallery with jqFancyTransitions. I hope that everything have been easy for you and you like our result. Good luck!