Foxy and friends are a lightweight group of slideshows. They use vanilla JS and CSS, and are otherwise without dependencies. They use grid and flexbox for layout, and won't interfere with the rest of your template.
Foxy is designed to display individual elements. All elements are layered on top of one another, and Foxy will expand to fit the largest element.
Fennecs is an extension to Foxy that displays multiple elements in a single slide. It is responsive, and will rearrange the elements to neatly fit inside a slide.
Fox Parade is designed to display a row or column of elements of arbitrary width/height. Unlike the other slideshows, it uses flex instead of grid for layout.
Add Foxy to your dependencies in package.json:
{
"dependencies":
{
"foxy": "git+https://Rizanola@bitbucket.org/Rizanola/foxy.git"
}
}
Run the appropriate install command:
Yarn:
yarn install
NPM:
npm install
Download the latest version of Foxy from Bitbucket
Unzip the archive and place the folder in amongst your website's files
Include the Foxy stylesheet:
<link rel="stylesheet" type="text/css" href="foxy/src/foxy.css" />
Include the Foxy JavaScript:
Global Foxy objects:
<script type="text/javascript" src="foxy/dist/foxy.min.js"></script>
As an ES6 module:
import { Foxy, Fennecs, FoxParade, FoxyDirection } from "foxy/dist/foxy.es6.js";
Add the foxy / fennecs / fox-parade classes to the element you wish to add the slideshow to. This sets up the base styles, and prevents a FOUC from occurring.
<div class="foxy">
<img src="image-1.png" />
<img src="image-2.png" />
<img src="image-3.png" />
</div>
<div class="fennecs">
<img src="image-1.png" />
<img src="image-2.png" />
<img src="image-3.png" />
</div>
<div class="fox-parade">
<img src="image-1.png" />
<img src="image-2.png" />
<img src="image-3.png" />
</div>
Trigger the Foxy.init() / Fennecs.init() / FoxParade.init() method on your element in one of the following ways:
With a selector:
Foxy.init(".js-foxy", options);
Fennecs.init(".js-fennecs", options);
FoxParade.init(".js-fox-parade", options);
With a single element:
Foxy.init(myElement, options);
Fennecs.init(myElement, options);
FoxParade.init(myElement, options);
With an entire array of elements:
Foxy.init(myElements, options);
Fennecs.init(myElements, options);
FoxParade.init(myElements, options);
The options parameter is an object containing various settings to pass to Foxy. A description of the options can be found in the options section below.
Make sure that the element is available (added to the DOM), before you try to initialise Foxy on it.
The following options can be passed to the Foxy init() and set() methods
HTMLElement for an external element to place the arrows into. This will only be used if arrows are set to true.null to disable. Default is 3000.foxy-ANIMATION_NAME to the base foxy element. Native animation functions are fade, fade-in, instant, slide and vertical-slide, but you can easily create your own. Default is slide.undefined.--rows custom property.Foxy supports the following methods:
elements parameter is either a query string, a single HTMLElement or an array of HTMLElements the options parameter is described in the options section above.HTMLElement, it will return the Foxy instance associated with it. Will return undefined if Foxy has not been initialised on that element.foxy.set("timer", 4000).set("bullets", false);HTMLElementsHTMLElement, and returns the slide index for that elementHTMLElement or an slide index for the first parameter. The second parameter is optionally one of the FoxyDirection constants. If left on FoxyDirection.default, it will animate relative to the order of the slides.FoxyDirection.forward animation.FoxyDirection.backward animationFoxy tries to be lightweight and unobtrusive, however custom styling has the potential to conflict with the standard Foxy styles:
Foxy is built on top of CSS grid. This means that slide dimensions are responsively handled by the browser. Please refrain from changing the display property. You can use the inline-grid class to switch to an inline slideshow.
In order to setup columns for Fennecs, just use the normal grid-template-columns property that you'd use for a regular grid. e.g. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))
If you want the slideshow to flow vertically, especially with Fennecs or Fox Parade, you should add the foxy-vertical class to your slideshow element.
Foxy uses transform for slide animations, and opacity for fade animations. It also uses the various animation properties to handle animations. If your elements need these styles as well, you might consider wrapping them in <div> elements, which Foxy can style independently.
By default, Foxy centres all slides vertically and horizontally. This is convenient, but a pain to reset sometimes, so you can add a class of foxy-custom-alignment to the slideshow element in order for Foxy not to set the slide alignment.
If you're creating your own animation, the classes Foxy uses on its current and previous slides are foxy-current and foxy-departed. Foxy sets foxy-direction-forward and foxy-direction-backward on the slideshow element in order to animate directions correctly.
Foxy uses CSS variables to control the animations. If you're making custom animations, you'll want to keep track of these variables:
The --animation-speed variable defines how quickly an animation should run. This variable is set by the CSS, so can be overridden.
The --full-width and --full-height variables define the width and height of the slideshow element. You can use this to calculate relative positions for sliding animations. These variables are calculated by JavaScript, so they shouldn't be used for initial styling.
Fox Parade doesn't use --full-width or --full-height, but it uses --inner-width and --inner-height for calculating the internal scroll dimension.
It can sometimes look a little strange to have slides immediately abutting each other during a sliding animation, so if you want a visible gap between slides during the "slide" or "vertical-slide" animations, you can use the --slide-gap variable to define extra spacing.
The --animation-delay variable uses the --animation-speed variable and the drag distance to work out how far the animation should be negatively delayed while dragging. Foxy automatically applies this to all top level slides, but you may need to tinker with things a little if you have multiple levels of animation.
In addition; while the foxy-dragging class is applied to the slideshow element, slideshow specific animations should be paused.
Foxy.init(element, { animation: "instant" });
Foxy.init(element, { animation: "fade" });
Foxy.init(element, { animation: "fade-in" });
Note: Fade-in only looks good on opaque items of the same size
Foxy.init(element, { animation: "slide" });
Foxy.init(element, { animation: "vertical-slide" });
Note: We're using the foxy-vertical class to reorient the elements vertically. This is not required for the animation, it just looks nicer.
Foxy.init(element, { arrowsParent: ".js-external-arrows", bulletsParent: ".js-external-bullets" });
gap: 10px;
grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
Fennecs.init(element, { rows: 2 });
FoxParade.init(element);