# mixitup.Config
## Overview
`mixitup.Config` is an interface used for customising the functionality of a
mixer instance. It is organised into several semantically distinct sub-objects,
each one pertaining to a particular aspect of MixItUp functionality.
An object literal containing any or all of the available properies,
known as the "configuration object", can be passed as the second parameter to
the `mixitup` factory function when creating a mixer instance to customise its
functionality as needed.
If no configuration object is passed, the mixer instance will take on the default
configuration values detailed below.
### Contents
- [animation](#animation)
- [behavior](#behavior)
- [callbacks](#callbacks)
- [controls](#controls)
- [classNames](#classNames)
- [data](#data)
- [debug](#debug)
- [layout](#layout)
- [load](#load)
- [selectors](#selectors)
- [render](#render)
animation
A group of properties defining the mixer's animation and effects settings.
### enable
A boolean dictating whether or not animation should be enabled for the MixItUp instance.
If `false`, all operations will occur instantly and syncronously, although callback
functions and any returned promises will still be fulfilled.
|Type | Default
|--- | ---
|`boolean`| `true`
###### Example: Create a mixer with all animations disabled
```js
var mixer = mixitup(containerEl, {
animation: {
enable: false
}
});
```
### effects
A string of one or more space-seperated properties to which transitions will be
applied for all filtering animations.
Properties can be listed any order or combination, although they will be applied in a specific
predefined order to produce consistent results.
To learn more about available effects, experiment with our
sandbox demo and try out the "Export config" button in the Animation options drop down.
|Type | Default
|--- | ---
|`string`| `'fade scale'`
###### Example: Apply "fade" and "translateZ" effects to all animations
```js
// As targets are filtered in and out, they will fade between
// opacity 1 and 0 and transform between translateZ(-100px) and
// translateZ(0).
var mixer = mixitup(containerEl, {
animation: {
effects: 'fade translateZ(-100px)'
}
});
```
### effectsIn
A string of one or more space-seperated effects to be applied only to filter-in
animations, overriding `config.animation.effects` if set.
|Type | Default
|--- | ---
|`string`| `''`
###### Example: Apply downwards vertical translate to targets being filtered in
```js
var mixer = mixitup(containerEl, {
animation: {
effectsIn: 'fade translateY(-100%)'
}
});
```
### effectsOut
A string of one or more space-seperated effects to be applied only to filter-out
animations, overriding `config.animation.effects` if set.
|Type | Default
|--- | ---
|`string`| `''`
###### Example: Apply upwards vertical translate to targets being filtered out
```js
var mixer = mixitup(containerEl, {
animation: {
effectsOut: 'fade translateY(-100%)'
}
});
```
### duration
An integer dictating the duration of all MixItUp animations in milliseconds, not
including any additional delay apllied via the `'stagger'` effect.
|Type | Default
|--- | ---
|`number`| `600`
###### Example: Apply an animation duration of 200ms to all mixitup animations
```js
var mixer = mixitup(containerEl, {
animation: {
duration: 200
}
});
```
### easing
A valid CSS3 transition-timing function or shorthand. For a full list of accepted
values, visit easings.net.
|Type | Default
|--- | ---
|`string`| `'ease'`
###### Example 1: Apply "ease-in-out" easing to all animations
```js
var mixer = mixitup(containerEl, {
animation: {
easing: 'ease-in-out'
}
});
```
###### Example 2: Apply a custom "cubic-bezier" easing function to all animations
```js
var mixer = mixitup(containerEl, {
animation: {
easing: 'cubic-bezier(0.645, 0.045, 0.355, 1)'
}
});
```
### applyPerspective
A boolean dictating whether or not to apply perspective to the MixItUp container
during animations. By default, perspective is always applied and creates the
illusion of three-dimensional space for effects such as `translateZ`, `rotateX`,
and `rotateY`.
You may wish to disable this and define your own perspective settings via CSS.
|Type | Default
|--- | ---
|`bolean`| `true`
###### Example: Prevent perspective from being applied to any 3D transforms
```js
var mixer = mixitup(containerEl, {
animation: {
applyPerspective: false
}
});
```
### perspectiveDistance
The perspective distance value to be applied to the container during animations,
affecting any 3D-transform-based effects.
|Type | Default
|--- | ---
|`string`| `'3000px'`
###### Example: Set a perspective distance of 2000px
```js
var mixer = mixitup(containerEl, {
animation: {
effects: 'rotateY(-25deg)',
perspectiveDistance: '2000px'
}
});
```
### perspectiveOrigin
The perspective-origin value to be applied to the container during animations,
affecting any 3D-transform-based effects.
|Type | Default
|--- | ---
|`string`| `'50% 50%'`
###### Example: Set a perspective origin in the top-right of the container
```js
var mixer = mixitup(containerEl, {
animation: {
effects: 'transateZ(-200px)',
perspectiveOrigin: '100% 0'
}
});
```
### queue
A boolean dictating whether or not to enable the queuing of operations.
If `true` (default), and a control is clicked or an API call is made while another
operation is progress, the operation will go into the queue and will be automatically exectuted
when the previous operaitons is finished.
If `false`, any requested operations will be ignored, and the `onMixBusy` callback and `mixBusy`
event will be fired. If `debug.showWarnings` is enabled, a console warning will also occur.
|Type | Default
|--- | ---
|`boolean`| `true`
###### Example: Disable queuing
```js
var mixer = mixitup(containerEl, {
animation: {
queue: false
}
});
```
### queueLimit
An integer dictacting the maximum number of operations allowed in the queue at
any time, when queuing is enabled.
|Type | Default
|--- | ---
|`number`| `3`
###### Example: Allow a maximum of 5 operations in the queue at any time
```js
var mixer = mixitup(containerEl, {
animation: {
queueLimit: 5
}
});
```
### animateResizeContainer
A boolean dictating whether or not to transition the height and width of the
container as elements are filtered in and out. If disabled, the container height
will change abruptly.
It may be desirable to disable this on mobile devices as the CSS `height` and
`width` properties do not receive GPU-acceleration and can therefore cause stuttering.
|Type | Default
|--- | ---
|`boolean`| `true`
###### Example 1: Disable the transitioning of the container height and/or width
```js
var mixer = mixitup(containerEl, {
animation: {
animateResizeContainer: false
}
});
```
###### Example 2: Disable the transitioning of the container height and/or width for mobile devices only
```js
var mixer = mixitup(containerEl, {
animation: {
animateResizeContainer: myFeatureTests.isMobile ? false : true
}
});
```
### animateResizeTargets
A boolean dictating whether or not to transition the height and width of target
elements as they change throughout the course of an animation.
This is often a must for flex-box grid layouts where the size of target elements may change
depending on final their position in relation to their siblings, or for `.changeLayout()`
operations where the size of targets change between layouts.
NB: This feature requires additional calculations and manipulation to non-hardware-accelerated
properties which may adversely affect performance on slower devices, and is therefore
disabled by default.
|Type | Default
|--- | ---
|`boolean`| `false`
###### Example: Enable the transitioning of target widths and heights
```js
var mixer = mixitup(containerEl, {
animation: {
animateResizeTargets: true
}
});
```
### staggerSequence
A custom function used to manipulate the order in which the stagger delay is
incremented when using the ‘stagger’ effect.
When using the 'stagger' effect, the delay applied to each target element is incremented
based on its index. You may create a custom function to manipulate the order in which the
delay is incremented and create engaging non-linear stagger effects.
The function receives the index of the target element as a parameter, and must
return an integer which serves as the multiplier for the stagger delay.
|Type | Default
|--- | ---
|`function`| `null`
###### Example 1: Stagger target elements by column in a 3-column grid
```js
var mixer = mixitup(containerEl, {
animation: {
effects: 'fade stagger(100ms)',
staggerSequence: function(i) {
return i % 3;
}
}
});
```
###### Example 2: Using an algorithm to produce a more complex sequence
```js
var mixer = mixitup(containerEl, {
animation: {
effects: 'fade stagger(100ms)',
staggerSequence: function(i) {
return (2*i) - (5*((i/3) - ((1/3) * (i%3))));
}
}
});
```
### reverseOut
A boolean dictating whether or not to reverse the direction of `translate`
and `rotate` transforms for elements being filtered out.
It can be used to create carousel-like animations where elements enter and exit
from opposite directions. If enabled, the effect `translateX(-100%)` for elements
being filtered in would become `translateX(100%)` for targets being filtered out.
This functionality can also be achieved by providing seperate effects
strings for `config.animation.effectsIn` and `config.animation.effectsOut`.
|Type | Default
|--- | ---
|`boolean`| `false`
###### Example: Reverse the desired direction on any translate/rotate effect for targets being filtered out
```js
// Elements being filtered in will be translated from '100%' to '0' while
// elements being filtered out will be translated from 0 to '-100%'
var mixer = mixitup(containerEl, {
animation: {
effects: 'fade translateX(100%)',
reverseOut: true,
nudge: false // Disable nudging to create a carousel-like effect
}
});
```
### nudge
A boolean dictating whether or not to "nudge" the animation path of targets
when they are being filtered in and out simulatenously.
This has been the default behavior of MixItUp since version 1, but it
may be desirable to disable this effect when filtering directly from
one exclusive set of targets to a different exclusive set of targets,
to create a carousel-like effect, or a generally more subtle animation.
|Type | Default
|--- | ---
|`boolean`| `true`
###### Example: Disable the "nudging" of targets being filtered in and out simulatenously
```js
var mixer = mixitup(containerEl, {
animation: {
nudge: false
}
});
```
### clampHeight
A boolean dictating whether or not to clamp the height of the container while MixItUp's
geometry tests are carried out before an operation.
To prevent scroll-bar flicker, clamping is turned on by default. But in the case where the
height of the container might affect its vertical positioning in the viewport
(e.g. a vertically-centered container), this should be turned off to ensure accurate
test results and a smooth animation.
|Type | Default
|--- | ---
|`boolean`| `true`
###### Example: Disable container height-clamping
```js
var mixer = mixitup(containerEl, {
animation: {
clampHeight: false
}
});
```
### clampWidth
A boolean dictating whether or not to clamp the width of the container while MixItUp's
geometry tests are carried out before an operation.
To prevent scroll-bar flicker, clamping is turned on by default. But in the case where the
width of the container might affect its horitzontal positioning in the viewport
(e.g. a horizontall-centered container), this should be turned off to ensure accurate
test results and a smooth animation.
|Type | Default
|--- | ---
|`boolean`| `true`
###### Example: Disable container width-clamping
```js
var mixer = mixitup(containerEl, {
animation: {
clampWidth: false
}
});
```
behavior
A group of properties relating to the behavior of the Mixer.
### liveSort
A boolean dictating whether to allow "live" sorting of the mixer.
Because of the expensive nature of sorting, MixItUp makes use of several
internal optimizations to skip redundant sorting operations, such as when
the newly requested sort command is the same as the active one. The caveat
to this optimization is that "live" edits to the value of a target's sorting
attribute will be ignored when requesting a re-sort by the same attribute.
By setting to `behavior.liveSort` to `true`, the mixer will always re-sort
regardless of whether or not the sorting attribute and order have changed.
|Type | Default
|--- | ---
|`boolean`| `false`
###### Example: Enabling `liveSort` to allow for re-sorting
```js
var mixer = mixitup(containerEl, {
behavior: {
liveSort: true
},
load: {
sort: 'edited:desc'
}
});
var target = containerEl.children[3];
console.log(target.getAttribute('data-edited')); // '2015-04-24'
target.setAttribute('data-edited', '2017-08-10'); // Update the target's edited date
mixer.sort('edited:desc')
.then(function(state) {
// The target is now at the top of the list
console.log(state.targets[0] === target); // true
});
```