fancyBox
fancyBox is a tool that offers a nice and elegant way to add zooming functionality for images, html content and multi-media on your webpages.
More information and examples: http://www.fancyapps.com/fancybox/
License: http://www.fancyapps.com/fancybox/#license
Copyright (c) 2012 Janis Skarnelis - janis@fancyapps.com
How to use
To get started, download the plugin, unzip it and copy files to your website/application directory. Load files in the section of your HTML document. Make sure you also add the jQuery library.
Create your links with a title
(or data-fancybox-title
) if you want a title to be shown, and add a class:
If you have a set of related items that you would like to group,
additionally include a group name in the rel
(or data-fancybox-group
) attribute:
Initialise the script like this:
May also be passed an optional options object which will extend the default values. Example:
Tip: Automatically group and apply fancyBox to all images:
;
Script uses the href
attribute of the matched elements to obtain the location of the content and to figure out content type you want to display.
You can specify type directly by adding classname (fancybox.image, fancybox.iframe, etc) or data-fancybox-type
attribute:
//Ajax:Example//orExample //Iframe:Example //Inline (will display an element with `id="example"`)Example //SWF:Example //Image:Example
Note, ajax requests are subject to the same origin policy. If fancyBox will not be able to get content type, it will try to guess based on 'href' and will quit silently if would not succeed. (this is different from previsous versions where 'ajax' was used as default type or an error message was displayed).
Advanced
Helpers
Helpers provide a simple mechanism to extend the capabilities of fancyBox. There are two built-in helpers - 'overlay' and 'title'. You can disable them, set custom options or enable other helpers. Examples:
//Disable title helper; //Disable overlay helper; //Change title position and overlay color; //Enable thumbnail helper and set custom options;
API
Also available are event driven callback methods. The this
keyword refers to the current or upcoming object (depends on callback method). Here is how you can change title:
;
It`s possible to open fancyBox programmatically in various ways:
//HTML content:$; //DOM element:$; //Custom object:$; //Array of objects:$;
There are several methods that allow you to interact with and manipulate fancyBox, example:
//Close fancybox:$fancybox;
There is a simply way to access wrapping elements using JS:
$fancyboxwrap$fancyboxskin$fancyboxouter$fancyboxinner
You can override CSS to customize the look. For example, make navigation arrows always visible, change width and move them outside of area (use this snippet after including fancybox.css):
In that case, you might want to increase space around box:
;
Bug tracker
Have a bug? Please create an issue on GitHub at https://github.com/fancyapps/fancyBox/issues