QuickFlip Plugin for jQuery - Documentation
Created by Jon Raasch
QuickFlip 2 for jQuery is a plugin that flips any piece of HTML markup over like a card. The plugin supports any markup and styling, and uses an animation shortcut that is barely noticeable when fired quickly.
Download QuickFlip Plugin for jQuery- Basic use of QuickFlip 2
- QuickFlip examples
- Exposed functions in QuickFlip 2
- Customizable options for QuickFlip 2
- Advanced functions in QuickFlip 2
- Troubleshooting
- QuickFlip version history
- Upcoming enhancements for QuickFlip
- Known Issues
- Licensing of QuickFlip
Basic use of QuickFlip 2
Let's start with the markup. Since QuickFlip flips between a number of panels, we'll need a wrapper for each of them, which we will then need to wrap with something we can target:
<div class="quickflip-wrapper">
<div>Front panel content</div>
<div>Back panel content</div>
</div>
Next let's be sure we've included jquery.quickflip.js and the jquery library, then call $.quickFlip()
on our wrapper when the page loads:
$(function() {
$('.quickflip-wrapper').quickFlip();
});
This will attach the QuickFlip to this node. QuickFlip automatically attaches a click event to anything with the class "quickFlipCta". To take advantage of this we can use a couple links:
<div class="quickflip-wrapper">
<div>
<a href="#" class="quickFlipCta">Click to flip front panel</a>
</div>
<div>
<a href="#" class="quickFlipCta">Click to flip back panel</a>
</div>
</div>
Alternately, we can trigger the flip effect using the $.quickFlipper()
function. Simply chain this to any jQuery object:
$('.quickflip-wrapper').quickFlipper();
This can be attached to a click or hover event, or the custom function of your choice. Additionally, $.quickFlipper()
will initiate the QuickFlip if $.quickFlip()
hasn't yet been called on the given node. However it is best to pre-load the quickFlip for performance reasons.
(If you only use $.quickFlipper()
you should predefine some CSS styles: position: relative
for your wrapper and position: absolute
for each panel within)
QuickFlip examples
Exposed Functions in QuickFlip 2
$.quickFlip( options )
Initiates the QuickFlip on the given node, attaching CSS styles and appending necessary DOM elements.
options
(Object)
Option values (see below).
$.quickFlipper( options, nextPanel, repeater )
Triggers the flip effect. If $.quickFlip()
hasn't been called on the given node, $.quickFlipper()
will call it first.
options
(Object)
Option values (see below). These options will overwrite any set in $.quickFlip()
.
nextPanel
(Integer)
Index of the next panel to be shown. By default this is null
which automatically shows the next panel in the DOM, looping to the first panel if this doesn't exist.
repeater
(Integer)
Number of times to flip the panel, set to -1
to repeat the flip effect indefinitely.
$.whichQuickFlip()
Determines the QuickFlip index of the node it is called upon. This assists with interfacing with the $.quickFlip.flip()
function (which you shouldn't really have to use).
Customizable options for QuickFlip 2
closeSpeed
(Number)
The number of milliseconds it takes to flip over and hide the front panel.
openSpeed
(Number)
The number of milliseconds it takes to flip over and show the back panel.
vertical
(Boolean)
Whether or not to flip vertically - defaults to false
. Added in QuickFlip 2.1
easing
(String)
If you are using the jQuery easing plugin (http://gsgd.co.uk/sandbox/jquery/easing/) pass the string of the easing method you want to use. There are also two easing methods built into jQuery, linear
and swing
. By default easing is set to swing
.
ctaSelector
(jQuery Selector String)
QuickFlip attaches a click event to this jQuery selector that triggers the flip effect. Set to ''
, 0
or null
to stop the process and speed things up a tiny bit.
refresh
(Boolean)
Provides an option to refresh the QuickFlip animation each time a flip is called. This is useful if the content within the flip changes visually, however is turned off by default for performance reasons.
panelWidth
(Number or CSS string)
This sets the width of the QuickFlip panels statically, and prevents QuickFlip from automatically generating this value based on the panel's dimensions (this can also be accomplished through simple CSS).
panelHeight
(Number or CSS string)
This sets the height of the QuickFlip panels statically, and prevents QuickFlip from automatically generating this value based on the panel's dimensions (this can also be accomplished through simple CSS).
noResize
(Boolean)
Disables the window resize event which reattaches QuickFlip panels on window resize. Set this to true if your QuickFlip wrapper is not effected by the window size. Defaults to false
.
Advanced functions in QuickFlip 2
Coming soon...
Troubleshooting QuickFlip 2
QuickFlip is removing the margin / padding from my panels
QuickFlip's animation requires that the panel wrappers and main wrapper have no margin or padding, so the script forces this setting when it loads.
However the inner content of each panel can have any styling, so use an inner wrapper if you need margin or padding.
Portions of the QuickFlip panels are getting cut off
QuickFlip automatically pulls in the width and height of the first panel in the wrapper when $.quickFlip()
is called. This can cause problems if any of the later panels are smaller than the first, or if content loads dynamically into the panel (for example if an image loads).
The easiest way to get around this is to set a height and width for the QuickFlip panel, either via CSS or using the panelHeight
and panelWidth
QuickFlip options.
On page load the panels are tall for a moment, then flicker closed
When $.quickFlip()
loads it aapplies some CSS to hide all but the initial panel. This will cause a brief flicker when the page loads, unless you apply this CSS ahead of time.
The main styles to apply are position: relative
to the QuickFlip wrapper, and position: absolute
to the inner panel containers. You may also want to define a height and width for the wrapper panel.
Other panel height and width issues
If you are having other height and width issues, try applying a height and width to the main QuickFlip wrapper either via CSS or using the panelHeight
and panelWidth
QuickFlip options.
Version history for QuickFlip
QuickFlip 2.1.1
Released 08.23.2010
- Fixes typo breaking noResize option
- Fixes issues with passing options to $.quickFlipper
QuickFlip 2.1
Released 11.23.2009
- Vertical QuickFlip added
- Using jQuery's
clone()
method to duplicate the panels in the flip effect rather than custom methods (substantial performance boost with more robust cloning) - Addition of noResize option to disable the window resize event
- Reorganization and removal of unnecessary function associated with this release
QuickFlip 2.0.1
Released 11.22.2009
- Minified version included with download - using YUI Compressor the filesize is 4kb :)
- Small changes to allow YUI compressor to better compress the file (variable definitions chained etc.)
- Small performance boost on line 70 - using
$('#blah').find('.blah')
instead of$('.blah', '#blah');
QuickFlip 2
Released 07.13.2009
- Major reworking of QuickFlip structure
$.quickFlip()
can be chained from jQuery selectors- New
$.quickFlipper()
function is a vast improvement to$.quickFlip.flip()
, since it can be chained to a jQuery selector and doesn't need to be passed any information $.quickFlipper
also initiates$.quickFlip()
if it hasn't been called on the given node- QuickFlip 2 automatically applies necessary CSS styling, removing need for stylesheet inclusion
- QuickFlip 2 automatically pulls in CSS dimensions, removing the need to define panel dimensions
- Perfomance tuned
- Namespacing issues with other Javascript libraries resolved
- Browser error when using jquery v. 1.3.2 and IE8 resolved
QuickFlip (original)
Released 10.20.2008
- jQuery flip effect that supports any type of HTML content
- Requires certain classes to be applied in the markup
- Requires some CSS styles and panel dimensions to be defined
$.quickFlip.flip()
function can be used to trigger the flip, but needs to be passed the index of the quickFlip wrapper and the index of the next panel to show
Upcoming enhancements to QuickFlip
- An option to resize and reappend the QuickFlip panels when the browser window is resized. This will solve a minor bug that occurs when using a percentage width for the QuickFlip panel and resizing the window.
- The ability to pass -1 for the nextPanel option in $.quickFlipper() which will show the previous panel
Known Issues
- There is an issue with CSS-applied bottom borders being hidden during the flipping animation. This issue is due to the height being incorrectly calculated, which hides the overflow. There is currently no fix in the works for this issue.
- A white space shows during the flipping animation when Firebug 1.4.0b7 is active and QuickFlip is called on a node with a width based on the percentage of the window width. This disappears when Firebug is minimized, so this is not an issue.
Licensing of QuickFlip 2
QuickFlip 2 is released under the FreeBSD license:
Copyright (c) 2009 Jon Raasch (http://jonraasch.com/)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY JON RAASCH 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JON RAASCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Jon Raasch, who is the man.