Skip to content
This repository was archived by the owner on Aug 24, 2020. It is now read-only.

Commit 201183e

Browse files
- Change default behaviour, don't touch dom
- Add sortChild in config to do so - Mode preprend option to config
1 parent c2457c7 commit 201183e

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

src/app/modules/ionic-swing/interfaces/swing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export interface StackConfig {
7979
maxRotation?: number;
8080
allowedDirections?: Array<any>;
8181

82+
sortChild?: boolean;
83+
prependChild?: boolean;
84+
8285
/**
8386
* Determines if element is being thrown out of the stack.
8487
*

src/app/modules/ionic-swing/swing/card.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ const makeConfig = (config = {}) => {
173173
rotation: rotation,
174174
throwOutConfidence: throwOutConfidence,
175175
throwOutDistance: throwOutDistance,
176-
transform: transform
176+
transform: transform,
177+
sortChild: false,
178+
prependChild: false
177179
};
178180

179181
return _.assign({}, defaultConfig, config);
@@ -182,10 +184,9 @@ const makeConfig = (config = {}) => {
182184
/**
183185
* param {Stack} stack
184186
* param {HTMLElement} targetElement
185-
* param {boolean} prepend
186187
* returns {Object} An instance of Card.
187188
*/
188-
const Card = (stack, targetElement, prepend) => {
189+
const Card = (stack, targetElement) => {
189190
let card;
190191
let config;
191192
let currentX;
@@ -246,14 +247,18 @@ const Card = (stack, targetElement, prepend) => {
246247
]
247248
});
248249

249-
if (prepend) {
250-
prependToParent(targetElement);
251-
} else {
252-
appendToParent(targetElement);
250+
if (config.sortChild) {
251+
if (config.prependChild) {
252+
prependToParent(targetElement);
253+
} else {
254+
appendToParent(targetElement);
255+
}
253256
}
254257

255258
eventEmitter.on('panstart', () => {
256-
appendToParent(targetElement);
259+
if (config.sortChild) {
260+
appendToParent(targetElement);
261+
}
257262

258263
eventEmitter.trigger('dragstart', {
259264
target: targetElement

src/app/modules/ionic-swing/swing/stack.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ export const Stack = (config) => {
5757
* Creates an instance of Card and associates it with an element.
5858
*
5959
* param {HTMLElement} element
60-
* param {boolean} prepend
6160
* returns {Card}
6261
*/
63-
stack.createCard = (element, prepend) => {
64-
const card = Card(stack, element, prepend);
62+
stack.createCard = (element) => {
63+
const card = Card(stack, element);
6564
const events = [
6665
'throwout',
6766
'throwoutend',

0 commit comments

Comments
 (0)