jQuery | Flipping Gallery Plugin

jQuery provides a simple, beautiful, and interactive flipping gallery plugin which helps programmers to flip many images in a gallery in various directions with the autoplay feature. The plugin is implemented by using HTML markups and simple javascript function call.

Please download the Flipping gallery plugin in your working folder and include all the relevant files in the head section of your landing web page.
Download link: https://github.com/peachananr/flipping_gallery

Example 1: In the following program, the simple call of flipping_gallery() function is shown for basic usage. Previous and Next buttons are provided for handling of flipping images in forward or backward movements.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>jQuery Flipping Gallery Plugin </title>
          
    <link href=
          rel='stylesheet' type='text/css'>
    <link href=
'http://fonts.googleapis.com/css?family=Noto+Serif:400, 
                     700, 400italic, 700italic'
          rel='stylesheet' type='text/css'>
                rel='stylesheet'
                type='text/css'>
    <link href='flipping_gallery.css' 
          rel='stylesheet' type='text/css'>
      
    <script type="text/javascript" 
            src="http://code.jquery.com/jquery-1.9.1.js">
     </script>
    <script type="text/javascript" 
            src="jquery.flipping_gallery.js">
      </script>
  <style>
    html
    {
      height: 90%;
    }
    body
    {
      padding: 0;
      text-align: center;
      font-family: 'open sans';
      position: relative;
      margin: 0;
      height: 80%;
    }
      
    .wrapper
    {
        height: auto !important;
        height: 60%;
        margin: 0 auto; 
        overflow: hidden;
    }
      
    
    {
      text-decoration: none;
    }
             
     .btn
     {
      display: inline-block;
      border: 4px solid black;
      border-radius: 4px;
      -moz-border-radius: 4px;
      -webkit-border-radius: 4px;
      background: green;
      display: inline-block;
      line-height: 100%;
      padding: 0.6em;
      text-decoration: none;
      color: #0d2633;
      width: 100px;
      line-height: 100%;
      font-size: 14px;
      font-family: open sans;
      font-weight: bold;
      border: none;
      margin-left: 10px;
    }
        
    .btns {
      width: 200px;
      margin: 20px auto;
      
    }
         
    .page-container {
      max-width: 700px;      
      margin: auto;
      position: relative;
    }
        
    .gallery {
      height: 300px;
      width: 500px;     
      margin: 150px auto 100px;
    
      
    img
    {
     border : 1px solid black;
    }
  
    </style>
    <script>
      $(document).ready( function() {
        $(".gallery").flipping_gallery();
          
        $(".next").click(function() {
          $(".gallery").flipForward();
          return false;
        });
        $(".prev").click(function() {
          $(".gallery").flipBackward();
          return false;
        });
      });
          
    </script>
</head>
<body>
    <h3 style="color:green">
           GeeksForGeeks - jQuery Flipping gallery
     </h3>             
  <div class="wrapper">            
      <div class="page-container">     
        <div class="gallery">
          <a href="#" data-caption="">
          <img src="images/geeksimage1.png" border="2"></a>
          <a href="#" data-caption="">
          <img src="images/geeksimage2.png" border="2"></a>
          <a href="#" data-caption="">
          <img src="images/geeksimage3.png" border="2"></a>
          <a href="#" data-caption="">
          <img src="images/gfg2.jpg" border="2"></a>
          <a href="#" data-caption="">
          <img src="images/gfg6.png" border="2"></a>          
          <a href="#" data-caption="">
          <img src="images/background.jpg" border="2"></a>
          <a href="#" data-caption="">
          <img src="images/background2.jpg" border="2"></a>
          <a href="#" data-caption="">
          <img src="images/background3.jpg" border="2"></a>         
        </div>      
  
        <div class="navigation">
          <a href="#" class="btn prev">Previous</a>
          <a href="#" class="btn next">Next</a>
        </div>
      </div>
     
  </div>
</body>
</html>

chevron_right


Output :

Example 2: In the following program, various options setting are implemented using javascript function call.The programmer can make use of various options depending on the application’s requirement. Please read the comments for each option values and use accordingly. Programmer can make use of data-caption attribute to add captions.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>jQuery Flipping Gallery Plugin </title>
          
    <link href=
          rel='stylesheet'
          type='text/css'>
    <link href=
'http://fonts.googleapis.com/css?family=Noto+Serif:400,
                    700, 400italic, 700italic'
          rel='stylesheet' type='text/css'>
          rel='stylesheet' type='text/css'>
    <link href='flipping_gallery.css' 
          rel='stylesheet' type='text/css'>
      
    <script type="text/javascript" 
            src="http://code.jquery.com/jquery-1.9.1.js">
    </script>
    <script type="text/javascript" src="jquery.flipping_gallery.js">
    </script>
  <style>
    html
    {
      height: 90%;
    }
    body
    {
      padding: 0;
      text-align: center;
      font-family: 'open sans';
      position: relative;
      margin: 0;
      height: 80%;
    }
      
    .wrapper
    {
        height: auto !important;
        height: 60%;
        margin: 0 auto; 
        overflow: hidden;
    }
      
    
    {
      text-decoration: none;
    }
             
     .btn
     {
      display: inline-block;
      border: 4px solid black;
      border-radius: 4px;
      -moz-border-radius: 4px;
      -webkit-border-radius: 4px;
      background: green;
      display: inline-block;
      line-height: 100%;
      padding: 0.6em;
      text-decoration: none;
      color: #0d2633;
      width: 100px;
      line-height: 100%;
      font-size: 14px;
      font-family: open sans;
      font-weight: bold;
      border: none;
      margin-left: 10px;
    }
        
    .btns {
      width: 200px;
      margin: 20px auto;
      
    }
         
    .page-container {
      max-width: 700px;      
      margin: auto;
      position: relative;
    }
        
    .gallery {
      height: 310px;
      width: 500px;     
      margin: 150px auto 100px;
    
      
    img
    {
     border : 1px solid black;
    }
     .navigation {
      margin-bottom: 150px;
    }
    </style>
    <script>
      $(document).ready( function() {
        $(".gallery").flipping_gallery({
/* The options for the flipping direction are "forward", or
 "backward". Default value is forward.*/
           direction: "forward", 
  
// Default selector is set for generation of the gallery.
           selector: "> a", 
  
/* Spacing between each photo in pixels in the gallery. 
    Default value is 10.*/
           spacing: 20, 
  
// Limit the number of photos in the viewport.
           showMaximum: 5, 
  
// Set the scrolling behavior. Default value is true.
           enableScroll: true,
  
 /* Direction to flip picture. Options are "left", 
"right", "top", "bottom". Default value is bottom.*/
           flipDirection: "left", 
  
// Autoplay time interval. Default value is false.
           autoplay: 1200 
        });
          
        $(".next").click(function() {
          $(".gallery").flipForward();
          return false;
        });
        $(".prev").click(function() {
          $(".gallery").flipBackward();
          return false;
        });
      });
          
    </script>
</head>
<body>
    <h3 style="color:green">
           GeeksForGeeks - jQuery Flipping gallery
     </h3>             
  <div class="wrapper">            
      <div class="page-container">     
        <div class="gallery">
          <a href="#" data-caption="GeeksForGeeks Logo">
          <img  src="images/geeksimage1.png" border="2"></a>
  
          <a href="#" data-caption="Learning computer science!">
          <img  src="images/geeksimage2.png" border="2"></a>
  
          <a href="#" data-caption="jQuery is fun.">
          <img src="images/geeksimage3.png" border="2"></a>
  
          <a href="#" data-caption="Geeks week contest">
          <img src="images/gfg2.jpg" border="2"></a>
  
          <a href="#" data-caption="WebTechnology classes">
          <img src="images/gfg6.png" border="2"></a>
  
          <a href="#" data-caption="Going thr links and hyperlinks">
          <img src="images/background.jpg" border="2"></a>
  
          <a href="#" data-caption="HTML fundamentals">
          <img src="images/background2.jpg" border="2"></a>
  
          <a href="#" data-caption="CSS tutorials">
          <img src="images/background3.jpg" border="2"></a>         
        </div>      
  
        <div class="navigation">
          <a href="#" class="btn prev">Previous</a>
          <a href="#" class="btn next">Next</a>
        </div>
      </div>
  </div>
</body>
</html>

chevron_right


Output:

In the following script, the option setting for flipping in top direction is shown. The programmers can similarly make use of other options as well for different flipping options.

filter_none

edit
close

play_arrow

link
brightness_4
code

$(document).ready( function() {
    $(".gallery").flipping_gallery({
         flipDirection: "top",
         autoplay: false
    });
});

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.