Skip to content

Commit

Permalink
v3.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkunka committed Jun 6, 2017
1 parent 4b0bebc commit a2fdba2
Show file tree
Hide file tree
Showing 15 changed files with 353 additions and 101 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

## 3.1.12
- Fixes issue where `state.targets` does not reflect the updated sort order after a sort operation.
- Addition of `behavior.liveSort` configuration option.

## 3.1.11

- Various geometry improvements related to scroll bar issues on desktop Windows and (non-inertial scroll) desktop Mac systems.
Expand Down
10 changes: 5 additions & 5 deletions demos/mixitup.min.js

Large diffs are not rendered by default.

84 changes: 81 additions & 3 deletions dist/mixitup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* MixItUp v3.1.11
* MixItUp v3.1.12
* A high-performance, dependency-free library for animated filtering, sorting and more
* Build df0ecdbb-7676-4e95-b437-ba1d1a4bff66
* Build 99123294-5817-4da9-b352-e17eb8780170
*
* @copyright Copyright 2014-2017 KunkaLabs Limited.
* @author KunkaLabs Limited.
Expand Down Expand Up @@ -2300,6 +2300,78 @@

mixitup.ConfigAnimation.prototype.constructor = mixitup.ConfigAnimation;

/**
* A group of properties relating to the behavior of the Mixer.
*
* @constructor
* @memberof mixitup.Config
* @name behavior
* @namespace
* @public
* @since 3.1.12
*/

mixitup.ConfigBehavior = function() {
mixitup.Base.call(this);

this.callActions('beforeConstruct');

/**
* 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.
*
* @example <caption>Example: Enabling `liveSort` to allow for re-sorting</caption>
*
* 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
* });
*
* @name liveSort
* @memberof mixitup.Config.behavior
* @instance
* @type {boolean}
* @default false
*/

this.liveSort = false;

this.callActions('afterConstruct');

h.seal(this);
};

mixitup.BaseStatic.call(mixitup.ConfigBehavior);

mixitup.ConfigBehavior.prototype = Object.create(mixitup.Base.prototype);

mixitup.ConfigBehavior.prototype.constructor = mixitup.ConfigBehavior;

/**
* A group of optional callback functions to be invoked at various
* points within the lifecycle of a mixer operation.
Expand Down Expand Up @@ -3759,6 +3831,7 @@
this.callActions('beforeConstruct');

this.animation = new mixitup.ConfigAnimation();
this.behavior = new mixitup.ConfigBehavior();
this.callbacks = new mixitup.ConfigCallbacks();
this.controls = new mixitup.ConfigControls();
this.classNames = new mixitup.ConfigClassNames();
Expand Down Expand Up @@ -7826,6 +7899,7 @@
result = false;

if (
self.config.behavior.liveSort ||
sortCommandA.order === 'random' ||
sortCommandA.attribute !== sortCommandB.attribute ||
sortCommandA.order !== sortCommandB.order ||
Expand Down Expand Up @@ -8524,6 +8598,10 @@
self.getTweenData(operation);
}

if (operation.willSort) {
self.targets = operation.newOrder;
}

operation.newState = self.buildState(operation);

return self.callFilters('operationMappedGetOperation', operation, arguments);
Expand Down Expand Up @@ -10557,5 +10635,5 @@
mixitup.BaseStatic.call(mixitup.constructor);

mixitup.NAME = 'mixitup';
mixitup.CORE_VERSION = '3.1.11';
mixitup.CORE_VERSION = '3.1.12';
})(window);
10 changes: 5 additions & 5 deletions dist/mixitup.min.js

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions docs/mixitup.Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ configuration values detailed below.
### Contents

- [animation](#animation)
- [behavior](#behavior)
- [callbacks](#callbacks)
- [controls](#controls)
- [classNames](#classNames)
Expand Down Expand Up @@ -538,6 +539,58 @@ var mixer = mixitup(containerEl, {
});
```

<h2 id="behavior">behavior</h2>

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
});
```

<h2 id="callbacks">callbacks</h2>

A group of optional callback functions to be invoked at various
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mixitup",
"title": "MixItUp",
"version": "3.1.11",
"version": "3.1.12",
"description": "A high-performance, dependency-free library for animated filtering, sorting and more",
"author": "KunkaLabs Limited",
"homepage": "https://www.kunkalabs.com/mixitup/",
Expand Down
73 changes: 73 additions & 0 deletions src/config-behavior.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* global mixitup, h */

/**
* A group of properties relating to the behavior of the Mixer.
*
* @constructor
* @memberof mixitup.Config
* @name behavior
* @namespace
* @public
* @since 3.1.12
*/

mixitup.ConfigBehavior = function() {
mixitup.Base.call(this);

this.callActions('beforeConstruct');

/**
* 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.
*
* @example <caption>Example: Enabling `liveSort` to allow for re-sorting</caption>
*
* 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
* });
*
* @name liveSort
* @memberof mixitup.Config.behavior
* @instance
* @type {boolean}
* @default false
*/

this.liveSort = false;

this.callActions('afterConstruct');

h.seal(this);
};

mixitup.BaseStatic.call(mixitup.ConfigBehavior);

mixitup.ConfigBehavior.prototype = Object.create(mixitup.Base.prototype);

mixitup.ConfigBehavior.prototype.constructor = mixitup.ConfigBehavior;
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mixitup.Config = function() {
this.callActions('beforeConstruct');

this.animation = new mixitup.ConfigAnimation();
this.behavior = new mixitup.ConfigBehavior();
this.callbacks = new mixitup.ConfigCallbacks();
this.controls = new mixitup.ConfigControls();
this.classNames = new mixitup.ConfigClassNames();
Expand Down
5 changes: 5 additions & 0 deletions src/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2914,6 +2914,7 @@ h.extend(mixitup.Mixer.prototype,
result = false;

if (
self.config.behavior.liveSort ||
sortCommandA.order === 'random' ||
sortCommandA.attribute !== sortCommandB.attribute ||
sortCommandA.order !== sortCommandB.order ||
Expand Down Expand Up @@ -3612,6 +3613,10 @@ h.extend(mixitup.Mixer.prototype,
self.getTweenData(operation);
}

if (operation.willSort) {
self.targets = operation.newOrder;
}

operation.newState = self.buildState(operation);

return self.callFilters('operationMappedGetOperation', operation, arguments);
Expand Down
2 changes: 2 additions & 0 deletions src/wrapper.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

{{>config-animation}}

{{>config-behavior}}

{{>config-callbacks}}

{{>config-controls}}
Expand Down
12 changes: 6 additions & 6 deletions tests/mock/dataset.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
[
{
"id": 1,
"id": "target-1",
"categories": ["a"],
"published": "20161102",
"views": 100
},
{
"id": 2,
"id": "target-2",
"categories": ["a"],
"published": "20130501",
"views": 54
},
{
"id": 3,
"id": "target-3",
"categories": ["b"],
"published": "20121231",
"views": 3
},
{
"id": 4,
"id": "target-4",
"categories": ["b"],
"published": "20160407",
"views": 62
},
{
"id": 5,
"id": "target-5",
"categories": ["c"],
"published": "20160820",
"views": 54
},
{
"id": 6,
"id": "target-6",
"categories": ["a", "c"],
"published": "20151020",
"views": 95
Expand Down
12 changes: 6 additions & 6 deletions tests/mock/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const renderElement = (html) => {
module.exports = {
getContainer() {
return renderElement('<div class="mixitup-container" data-ref="container">' +
'<div id="1" class="mix category-a" data-ref="mix" data-category="a" data-published="20161102" data-views="100"></div> ' +
'<div id="2" class="mix category-a" data-ref="mix" data-category="a" data-published="20130501" data-views="54"></div> ' +
'<div id="3" class="mix category-b" data-ref="mix" data-category="b" data-published="20121231" data-views="3"></div> ' +
'<div id="4" class="mix category-b" data-ref="mix" data-category="b" data-published="20160407" data-views="62"></div> ' +
'<div id="5" class="mix category-c" data-ref="mix" data-category="c" data-published="20160820" data-views="54"></div> ' +
'<div id="6" class="mix category-a category-c" data-ref="mix" data-category="a c" data-published="20151020" data-views="95"></div>' +
'<div id="target-1" class="mix category-a" data-ref="mix" data-category="a" data-published="20161102" data-views="100"></div> ' +
'<div id="target-2" class="mix category-a" data-ref="mix" data-category="a" data-published="20130501" data-views="54"></div> ' +
'<div id="target-3" class="mix category-b" data-ref="mix" data-category="b" data-published="20121231" data-views="3"></div> ' +
'<div id="target-4" class="mix category-b" data-ref="mix" data-category="b" data-published="20160407" data-views="62"></div> ' +
'<div id="target-5" class="mix category-c" data-ref="mix" data-category="c" data-published="20160820" data-views="54"></div> ' +
'<div id="target-6" class="mix category-a category-c" data-ref="mix" data-category="a c" data-published="20151020" data-views="95"></div>' +
'<span class="mixitup-container-gap></span>' +
'</div>');
},
Expand Down
Loading

0 comments on commit a2fdba2

Please sign in to comment.