New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

oribella-aurelia-sortable

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oribella-aurelia-sortable - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0-dev.20170717

0

dist/amd/auto-scroll.d.ts

@@ -0,0 +0,0 @@ import { ScrollData } from './utils';

6

dist/amd/auto-scroll.js

@@ -52,9 +52,9 @@ define(["require", "exports", "tslib", "aurelia-dependency-injection"], function (require, exports, tslib_1, aurelia_dependency_injection_1) {

};
AutoScroll = tslib_1.__decorate([
aurelia_dependency_injection_1.transient()
], AutoScroll);
return AutoScroll;
}());
AutoScroll = tslib_1.__decorate([
aurelia_dependency_injection_1.transient()
], AutoScroll);
exports.AutoScroll = AutoScroll;
});
//# sourceMappingURL=auto-scroll.js.map

@@ -0,0 +0,0 @@ import { Container } from 'aurelia-dependency-injection';

define(["require", "exports", "tslib", "aurelia-dependency-injection"], function (require, exports, tslib_1, aurelia_dependency_injection_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OptionalParent = OptionalParent_1 = (function () {
var OptionalParent = (function () {
var OptionalParent = OptionalParent_1 =
// tslint:disable-next-line:ban-types
function OptionalParent(key) {
this.key = key;
}
};
OptionalParent.prototype.get = function (container) {

@@ -14,13 +16,14 @@ if (container.parent && container.parent.hasResolver(this.key, true)) {

};
// tslint:disable-next-line:ban-types
OptionalParent.of = function (key) {
return new OptionalParent_1(key);
};
OptionalParent = OptionalParent_1 = tslib_1.__decorate([
aurelia_dependency_injection_1.resolver()
], OptionalParent);
return OptionalParent;
var OptionalParent_1;
}());
OptionalParent = OptionalParent_1 = tslib_1.__decorate([
aurelia_dependency_injection_1.resolver()
], OptionalParent);
exports.OptionalParent = OptionalParent;
var OptionalParent_1;
});
//# sourceMappingURL=optional-parent.js.map

@@ -0,0 +0,0 @@ import { FrameworkConfiguration } from 'aurelia-framework';

@@ -0,0 +0,0 @@ define(["require", "exports", "aurelia-pal", "oribella", "./auto-scroll", "./optional-parent", "./sortable", "./utils"], function (require, exports, aurelia_pal_1, OA, AS, OP, S, U) {

import { Repeat } from 'aurelia-templating-resources';
import { DefaultListenerArgs } from 'oribella';
import { DragClone } from './utils';
import { DragClone, Move } from './utils';
import { AutoScroll } from './auto-scroll';

@@ -26,3 +26,3 @@ export declare const SORTABLE = "oa-sortable";

axis: string;
onStop: () => void;
onStop: (move: Move) => void;
sortingClass: string;

@@ -54,2 +54,3 @@ dragClass: string;

private target;
private move;
constructor(element: Element, parentSortable: Sortable, autoScroll: AutoScroll);

@@ -56,0 +57,0 @@ activate(): void;

@@ -8,4 +8,4 @@ define(["require", "exports", "tslib", "aurelia-pal", "aurelia-templating", "aurelia-templating-resources", "aurelia-dependency-injection", "oribella", "./optional-parent", "./utils", "./auto-scroll"], function (require, exports, tslib_1, aurelia_pal_1, aurelia_templating_1, aurelia_templating_resources_1, aurelia_dependency_injection_1, oribella_1, optional_parent_1, utils_1, auto_scroll_1) {

exports.SORTABLE_ITEM_ATTR = "[" + exports.SORTABLE_ITEM + "]";
var Sortable = Sortable_1 = (function () {
function Sortable(element, parentSortable, autoScroll) {
var Sortable = (function () {
var Sortable = Sortable_1 = function Sortable(element, parentSortable, autoScroll) {
var _this = this;

@@ -63,4 +63,5 @@ this.element = element;

this.childSortables = [];
this.move = utils_1.DefaultInvalidMove;
this.sortableDepth = utils_1.utils.getSortableDepth(this);
}
};
Sortable.prototype.activate = function () {

@@ -107,7 +108,7 @@ this.removeListener = oribella_1.oribella.on(oribella_1.Swipe, this.element, this);

var vm = utils_1.utils.getViewModel(element);
var moveFlag = utils_1.utils.move(this.dragClone, vm);
if (moveFlag === utils_1.MoveFlag.Valid) {
this.move = utils_1.utils.move(this.dragClone, vm);
if (this.move.flag === utils_1.MoveFlag.Valid) {
this.lastElementFromPointRect = element.getBoundingClientRect();
}
if (moveFlag === utils_1.MoveFlag.ValidNewList) {
if (this.move.flag === utils_1.MoveFlag.ValidNewList) {
this.lastElementFromPointRect = { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 };

@@ -141,2 +142,3 @@ }

var evt = _a.evt, client = _a.data.pointers[0].client, target = _a.target;
this.move = utils_1.DefaultInvalidMove;
if (!this.isClosestSortable(evt.target)) {

@@ -169,57 +171,59 @@ return oribella_1.RETURN_FLAG.REMOVE;

Sortable.prototype.stop = function () {
if (this.target)
if (this.target) {
this.target.classList.remove(this.sortingClass);
}
utils_1.utils.removeDragClone(this.dragClone);
this.autoScroll.deactivate();
this.childSortables.forEach(function (s) { return s.isDisabled = false; });
this.onStop();
this.onStop(this.move);
};
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "items", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scroll", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSpeed", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSensitivity", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "axis", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "onStop", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "sortingClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragZIndex", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "disallowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelector", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowDrag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "typeFlag", void 0);
Sortable = Sortable_1 = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, optional_parent_1.OptionalParent.of(Sortable_1), auto_scroll_1.AutoScroll)
], Sortable);
return Sortable;
var Sortable_1;
}());
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "items", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scroll", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSpeed", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSensitivity", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "axis", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "onStop", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "sortingClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragZIndex", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "disallowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelector", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowDrag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "typeFlag", void 0);
Sortable = Sortable_1 = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, optional_parent_1.OptionalParent.of(Sortable_1), auto_scroll_1.AutoScroll)
], Sortable);
exports.Sortable = Sortable;

@@ -262,20 +266,19 @@ var SortableItem = (function () {

});
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "item", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "typeFlag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "lockedFlag", void 0);
SortableItem = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE_ITEM),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, aurelia_templating_resources_1.Repeat)
], SortableItem);
return SortableItem;
}());
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "item", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "typeFlag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "lockedFlag", void 0);
SortableItem = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE_ITEM),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, aurelia_templating_resources_1.Repeat)
], SortableItem);
exports.SortableItem = SortableItem;
var Sortable_1;
});
//# sourceMappingURL=sortable.js.map

@@ -34,2 +34,16 @@ import { Point } from 'oribella-framework';

}
export interface Move {
flag: MoveFlag;
fromItems: any[];
fromIndex: number;
toItems: any[];
toIndex: number;
}
export declare const DefaultInvalidMove: {
flag: MoveFlag;
fromItems: never[];
fromIndex: number;
toItems: never[];
toIndex: number;
};
export interface WindowDimension {

@@ -94,3 +108,3 @@ innerWidth: number;

getViewModel(element: SortableItemElement): SortableItem;
move(dragClone: DragClone, toVM: SortableItem): number;
move(dragClone: DragClone, toVM: SortableItem): Move;
pointInside({top, right, bottom, left}: Rect, {x, y}: Point): boolean;

@@ -97,0 +111,0 @@ elementFromPoint({x, y}: Point, selector: string, sortableElement: Element, dragClone: DragClone, axisFlag: AxisFlag): Element | null;

@@ -21,2 +21,3 @@ define(["require", "exports", "oribella-framework", "./sortable"], function (require, exports, oribella_framework_1, sortable_1) {

})(MoveFlag = exports.MoveFlag || (exports.MoveFlag = {}));
exports.DefaultInvalidMove = { flag: MoveFlag.Invalid, fromItems: [], fromIndex: -1, toItems: [], toIndex: -1 };
;

@@ -49,14 +50,14 @@ exports.utils = {

if (!fromVM) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
if (typeof toVM.lockedFlag === 'number' && (toVM.lockedFlag & LockedFlag.To) !== 0) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
var fromSortable = fromVM.parentSortable;
if (!fromSortable) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
var toSortable = toVM.parentSortable;
if (!toSortable) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}

@@ -67,3 +68,3 @@ var fromItem = fromVM.item;

if (fromSortable.sortableDepth !== toVM.childSortable.sortableDepth) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}

@@ -74,21 +75,21 @@ toSortable = toVM.childSortable;

if (fromVM.parentSortable !== toSortable && (fromVM.typeFlag & toSortable.typeFlag) === 0) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
if (fromSortable.sortableDepth !== toSortable.sortableDepth) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
var fromItems = fromSortable.items;
var fromIx = fromItems.indexOf(fromItem);
var fromIndex = fromItems.indexOf(fromItem);
var toItems = toSortable.items;
var toIx = toItems.indexOf(toItem);
if (toIx === -1) {
toIx = 0;
var toIndex = toItems.indexOf(toItem);
if (toIndex === -1) {
toIndex = 0;
}
var removedFromItem = fromItems.splice(fromIx, 1)[0];
toItems.splice(toIx, 0, removedFromItem);
var removedFromItem = fromItems.splice(fromIndex, 1)[0];
toItems.splice(toIndex, 0, removedFromItem);
if (changedToSortable) {
fromVM.parentSortable = toSortable;
return MoveFlag.ValidNewList;
return { flag: MoveFlag.ValidNewList, fromItems: fromItems, fromIndex: fromIndex, toItems: toItems, toIndex: toIndex };
}
return MoveFlag.Valid;
return { flag: MoveFlag.Valid, fromItems: fromItems, fromIndex: fromIndex, toItems: toItems, toIndex: toIndex };
},

@@ -95,0 +96,0 @@ pointInside: function (_a, _b) {

@@ -0,0 +0,0 @@ import { ScrollData } from './utils';

@@ -53,8 +53,8 @@ "use strict";

};
AutoScroll = tslib_1.__decorate([
aurelia_dependency_injection_1.transient()
], AutoScroll);
return AutoScroll;
}());
AutoScroll = tslib_1.__decorate([
aurelia_dependency_injection_1.transient()
], AutoScroll);
exports.AutoScroll = AutoScroll;
//# sourceMappingURL=auto-scroll.js.map

@@ -0,0 +0,0 @@ import { Container } from 'aurelia-dependency-injection';

@@ -5,6 +5,8 @@ "use strict";

var aurelia_dependency_injection_1 = require("aurelia-dependency-injection");
var OptionalParent = OptionalParent_1 = (function () {
var OptionalParent = (function () {
var OptionalParent = OptionalParent_1 =
// tslint:disable-next-line:ban-types
function OptionalParent(key) {
this.key = key;
}
};
OptionalParent.prototype.get = function (container) {

@@ -16,12 +18,13 @@ if (container.parent && container.parent.hasResolver(this.key, true)) {

};
// tslint:disable-next-line:ban-types
OptionalParent.of = function (key) {
return new OptionalParent_1(key);
};
OptionalParent = OptionalParent_1 = tslib_1.__decorate([
aurelia_dependency_injection_1.resolver()
], OptionalParent);
return OptionalParent;
var OptionalParent_1;
}());
OptionalParent = OptionalParent_1 = tslib_1.__decorate([
aurelia_dependency_injection_1.resolver()
], OptionalParent);
exports.OptionalParent = OptionalParent;
var OptionalParent_1;
//# sourceMappingURL=optional-parent.js.map

@@ -0,0 +0,0 @@ import { FrameworkConfiguration } from 'aurelia-framework';

@@ -0,0 +0,0 @@ "use strict";

import { Repeat } from 'aurelia-templating-resources';
import { DefaultListenerArgs } from 'oribella';
import { DragClone } from './utils';
import { DragClone, Move } from './utils';
import { AutoScroll } from './auto-scroll';

@@ -26,3 +26,3 @@ export declare const SORTABLE = "oa-sortable";

axis: string;
onStop: () => void;
onStop: (move: Move) => void;
sortingClass: string;

@@ -54,2 +54,3 @@ dragClass: string;

private target;
private move;
constructor(element: Element, parentSortable: Sortable, autoScroll: AutoScroll);

@@ -56,0 +57,0 @@ activate(): void;

@@ -16,4 +16,4 @@ "use strict";

exports.SORTABLE_ITEM_ATTR = "[" + exports.SORTABLE_ITEM + "]";
var Sortable = Sortable_1 = (function () {
function Sortable(element, parentSortable, autoScroll) {
var Sortable = (function () {
var Sortable = Sortable_1 = function Sortable(element, parentSortable, autoScroll) {
var _this = this;

@@ -71,4 +71,5 @@ this.element = element;

this.childSortables = [];
this.move = utils_1.DefaultInvalidMove;
this.sortableDepth = utils_1.utils.getSortableDepth(this);
}
};
Sortable.prototype.activate = function () {

@@ -115,7 +116,7 @@ this.removeListener = oribella_1.oribella.on(oribella_1.Swipe, this.element, this);

var vm = utils_1.utils.getViewModel(element);
var moveFlag = utils_1.utils.move(this.dragClone, vm);
if (moveFlag === utils_1.MoveFlag.Valid) {
this.move = utils_1.utils.move(this.dragClone, vm);
if (this.move.flag === utils_1.MoveFlag.Valid) {
this.lastElementFromPointRect = element.getBoundingClientRect();
}
if (moveFlag === utils_1.MoveFlag.ValidNewList) {
if (this.move.flag === utils_1.MoveFlag.ValidNewList) {
this.lastElementFromPointRect = { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 };

@@ -149,2 +150,3 @@ }

var evt = _a.evt, client = _a.data.pointers[0].client, target = _a.target;
this.move = utils_1.DefaultInvalidMove;
if (!this.isClosestSortable(evt.target)) {

@@ -177,57 +179,59 @@ return oribella_1.RETURN_FLAG.REMOVE;

Sortable.prototype.stop = function () {
if (this.target)
if (this.target) {
this.target.classList.remove(this.sortingClass);
}
utils_1.utils.removeDragClone(this.dragClone);
this.autoScroll.deactivate();
this.childSortables.forEach(function (s) { return s.isDisabled = false; });
this.onStop();
this.onStop(this.move);
};
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "items", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scroll", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSpeed", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSensitivity", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "axis", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "onStop", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "sortingClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragZIndex", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "disallowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelector", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowDrag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "typeFlag", void 0);
Sortable = Sortable_1 = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, optional_parent_1.OptionalParent.of(Sortable_1), auto_scroll_1.AutoScroll)
], Sortable);
return Sortable;
var Sortable_1;
}());
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "items", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scroll", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSpeed", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSensitivity", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "axis", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "onStop", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "sortingClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragZIndex", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "disallowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelector", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowDrag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "typeFlag", void 0);
Sortable = Sortable_1 = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, optional_parent_1.OptionalParent.of(Sortable_1), auto_scroll_1.AutoScroll)
], Sortable);
exports.Sortable = Sortable;

@@ -270,19 +274,18 @@ var SortableItem = (function () {

});
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "item", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "typeFlag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "lockedFlag", void 0);
SortableItem = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE_ITEM),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, aurelia_templating_resources_1.Repeat)
], SortableItem);
return SortableItem;
}());
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "item", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "typeFlag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "lockedFlag", void 0);
SortableItem = tslib_1.__decorate([
aurelia_templating_1.customAttribute(exports.SORTABLE_ITEM),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, aurelia_templating_resources_1.Repeat)
], SortableItem);
exports.SortableItem = SortableItem;
var Sortable_1;
//# sourceMappingURL=sortable.js.map

@@ -34,2 +34,16 @@ import { Point } from 'oribella-framework';

}
export interface Move {
flag: MoveFlag;
fromItems: any[];
fromIndex: number;
toItems: any[];
toIndex: number;
}
export declare const DefaultInvalidMove: {
flag: MoveFlag;
fromItems: never[];
fromIndex: number;
toItems: never[];
toIndex: number;
};
export interface WindowDimension {

@@ -94,3 +108,3 @@ innerWidth: number;

getViewModel(element: SortableItemElement): SortableItem;
move(dragClone: DragClone, toVM: SortableItem): number;
move(dragClone: DragClone, toVM: SortableItem): Move;
pointInside({top, right, bottom, left}: Rect, {x, y}: Point): boolean;

@@ -97,0 +111,0 @@ elementFromPoint({x, y}: Point, selector: string, sortableElement: Element, dragClone: DragClone, axisFlag: AxisFlag): Element | null;

@@ -22,2 +22,3 @@ "use strict";

})(MoveFlag = exports.MoveFlag || (exports.MoveFlag = {}));
exports.DefaultInvalidMove = { flag: MoveFlag.Invalid, fromItems: [], fromIndex: -1, toItems: [], toIndex: -1 };
;

@@ -50,14 +51,14 @@ exports.utils = {

if (!fromVM) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
if (typeof toVM.lockedFlag === 'number' && (toVM.lockedFlag & LockedFlag.To) !== 0) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
var fromSortable = fromVM.parentSortable;
if (!fromSortable) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
var toSortable = toVM.parentSortable;
if (!toSortable) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}

@@ -68,3 +69,3 @@ var fromItem = fromVM.item;

if (fromSortable.sortableDepth !== toVM.childSortable.sortableDepth) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}

@@ -75,21 +76,21 @@ toSortable = toVM.childSortable;

if (fromVM.parentSortable !== toSortable && (fromVM.typeFlag & toSortable.typeFlag) === 0) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
if (fromSortable.sortableDepth !== toSortable.sortableDepth) {
return MoveFlag.Invalid;
return exports.DefaultInvalidMove;
}
var fromItems = fromSortable.items;
var fromIx = fromItems.indexOf(fromItem);
var fromIndex = fromItems.indexOf(fromItem);
var toItems = toSortable.items;
var toIx = toItems.indexOf(toItem);
if (toIx === -1) {
toIx = 0;
var toIndex = toItems.indexOf(toItem);
if (toIndex === -1) {
toIndex = 0;
}
var removedFromItem = fromItems.splice(fromIx, 1)[0];
toItems.splice(toIx, 0, removedFromItem);
var removedFromItem = fromItems.splice(fromIndex, 1)[0];
toItems.splice(toIndex, 0, removedFromItem);
if (changedToSortable) {
fromVM.parentSortable = toSortable;
return MoveFlag.ValidNewList;
return { flag: MoveFlag.ValidNewList, fromItems: fromItems, fromIndex: fromIndex, toItems: toItems, toIndex: toIndex };
}
return MoveFlag.Valid;
return { flag: MoveFlag.Valid, fromItems: fromItems, fromIndex: fromIndex, toItems: toItems, toIndex: toIndex };
},

@@ -96,0 +97,0 @@ pointInside: function (_a, _b) {

@@ -0,0 +0,0 @@ import { ScrollData } from './utils';

@@ -0,0 +0,0 @@ import * as tslib_1 from "tslib";

@@ -0,0 +0,0 @@ import { Container } from 'aurelia-dependency-injection';

import * as tslib_1 from "tslib";
import { resolver } from 'aurelia-dependency-injection';
let OptionalParent = OptionalParent_1 = class OptionalParent {
// tslint:disable-next-line:ban-types
constructor(key) {

@@ -13,2 +14,3 @@ this.key = key;

}
// tslint:disable-next-line:ban-types
static of(key) {

@@ -15,0 +17,0 @@ return new OptionalParent_1(key);

@@ -0,0 +0,0 @@ import { FrameworkConfiguration } from 'aurelia-framework';

@@ -0,0 +0,0 @@ import { PLATFORM } from 'aurelia-pal';

import { Repeat } from 'aurelia-templating-resources';
import { DefaultListenerArgs } from 'oribella';
import { DragClone } from './utils';
import { DragClone, Move } from './utils';
import { AutoScroll } from './auto-scroll';

@@ -26,3 +26,3 @@ export declare const SORTABLE = "oa-sortable";

axis: string;
onStop: () => void;
onStop: (move: Move) => void;
sortingClass: string;

@@ -54,2 +54,3 @@ dragClass: string;

private target;
private move;
constructor(element: Element, parentSortable: Sortable, autoScroll: AutoScroll);

@@ -56,0 +57,0 @@ activate(): void;

@@ -8,3 +8,3 @@ import * as tslib_1 from "tslib";

import { OptionalParent } from './optional-parent';
import { utils, AxisFlag, LockedFlag, MoveFlag } from './utils';
import { utils, AxisFlag, LockedFlag, MoveFlag, DefaultInvalidMove } from './utils';
import { AutoScroll } from './auto-scroll';

@@ -67,2 +67,3 @@ export const SORTABLE = 'oa-sortable';

this.childSortables = [];
this.move = DefaultInvalidMove;
this.sortableDepth = utils.getSortableDepth(this);

@@ -111,7 +112,7 @@ }

const vm = utils.getViewModel(element);
const moveFlag = utils.move(this.dragClone, vm);
if (moveFlag === MoveFlag.Valid) {
this.move = utils.move(this.dragClone, vm);
if (this.move.flag === MoveFlag.Valid) {
this.lastElementFromPointRect = element.getBoundingClientRect();
}
if (moveFlag === MoveFlag.ValidNewList) {
if (this.move.flag === MoveFlag.ValidNewList) {
this.lastElementFromPointRect = { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 };

@@ -143,2 +144,3 @@ }

down({ evt, data: { pointers: [{ client }] }, target }) {
this.move = DefaultInvalidMove;
if (!this.isClosestSortable(evt.target)) {

@@ -169,8 +171,9 @@ return RETURN_FLAG.REMOVE;

stop() {
if (this.target)
if (this.target) {
this.target.classList.remove(this.sortingClass);
}
utils.removeDragClone(this.dragClone);
this.autoScroll.deactivate();
this.childSortables.forEach((s) => s.isDisabled = false);
this.onStop();
this.onStop(this.move);
}

@@ -177,0 +180,0 @@ };

@@ -34,2 +34,16 @@ import { Point } from 'oribella-framework';

}
export interface Move {
flag: MoveFlag;
fromItems: any[];
fromIndex: number;
toItems: any[];
toIndex: number;
}
export declare const DefaultInvalidMove: {
flag: MoveFlag;
fromItems: never[];
fromIndex: number;
toItems: never[];
toIndex: number;
};
export interface WindowDimension {

@@ -94,3 +108,3 @@ innerWidth: number;

getViewModel(element: SortableItemElement): SortableItem;
move(dragClone: DragClone, toVM: SortableItem): number;
move(dragClone: DragClone, toVM: SortableItem): Move;
pointInside({top, right, bottom, left}: Rect, {x, y}: Point): boolean;

@@ -97,0 +111,0 @@ elementFromPoint({x, y}: Point, selector: string, sortableElement: Element, dragClone: DragClone, axisFlag: AxisFlag): Element | null;

@@ -20,2 +20,3 @@ import { Point, matchesSelector } from 'oribella-framework';

})(MoveFlag || (MoveFlag = {}));
export const DefaultInvalidMove = { flag: MoveFlag.Invalid, fromItems: [], fromIndex: -1, toItems: [], toIndex: -1 };
;

@@ -48,14 +49,14 @@ export const utils = {

if (!fromVM) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
if (typeof toVM.lockedFlag === 'number' && (toVM.lockedFlag & LockedFlag.To) !== 0) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
const fromSortable = fromVM.parentSortable;
if (!fromSortable) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
let toSortable = toVM.parentSortable;
if (!toSortable) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}

@@ -66,3 +67,3 @@ const fromItem = fromVM.item;

if (fromSortable.sortableDepth !== toVM.childSortable.sortableDepth) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}

@@ -73,21 +74,21 @@ toSortable = toVM.childSortable;

if (fromVM.parentSortable !== toSortable && (fromVM.typeFlag & toSortable.typeFlag) === 0) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
if (fromSortable.sortableDepth !== toSortable.sortableDepth) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
const fromItems = fromSortable.items;
const fromIx = fromItems.indexOf(fromItem);
const fromIndex = fromItems.indexOf(fromItem);
const toItems = toSortable.items;
let toIx = toItems.indexOf(toItem);
if (toIx === -1) {
toIx = 0;
let toIndex = toItems.indexOf(toItem);
if (toIndex === -1) {
toIndex = 0;
}
const removedFromItem = fromItems.splice(fromIx, 1)[0];
toItems.splice(toIx, 0, removedFromItem);
const removedFromItem = fromItems.splice(fromIndex, 1)[0];
toItems.splice(toIndex, 0, removedFromItem);
if (changedToSortable) {
fromVM.parentSortable = toSortable;
return MoveFlag.ValidNewList;
return { flag: MoveFlag.ValidNewList, fromItems, fromIndex, toItems, toIndex };
}
return MoveFlag.Valid;
return { flag: MoveFlag.Valid, fromItems, fromIndex, toItems, toIndex };
},

@@ -94,0 +95,0 @@ pointInside({ top, right, bottom, left }, { x, y }) {

@@ -0,0 +0,0 @@ import { ScrollData } from './utils';

@@ -63,7 +63,7 @@ System.register(["tslib", "aurelia-dependency-injection"], function (exports_1, context_1) {

};
AutoScroll = tslib_1.__decorate([
aurelia_dependency_injection_1.transient()
], AutoScroll);
return AutoScroll;
}());
AutoScroll = tslib_1.__decorate([
aurelia_dependency_injection_1.transient()
], AutoScroll);
exports_1("AutoScroll", AutoScroll);

@@ -70,0 +70,0 @@ }

@@ -0,0 +0,0 @@ import { Container } from 'aurelia-dependency-injection';

System.register(["tslib", "aurelia-dependency-injection"], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var tslib_1, aurelia_dependency_injection_1, OptionalParent, OptionalParent_1;
var tslib_1, aurelia_dependency_injection_1, OptionalParent;
return {

@@ -15,6 +15,8 @@ setters: [

execute: function () {
OptionalParent = OptionalParent_1 = (function () {
OptionalParent = (function () {
var OptionalParent = OptionalParent_1 =
// tslint:disable-next-line:ban-types
function OptionalParent(key) {
this.key = key;
}
};
OptionalParent.prototype.get = function (container) {

@@ -26,10 +28,12 @@ if (container.parent && container.parent.hasResolver(this.key, true)) {

};
// tslint:disable-next-line:ban-types
OptionalParent.of = function (key) {
return new OptionalParent_1(key);
};
OptionalParent = OptionalParent_1 = tslib_1.__decorate([
aurelia_dependency_injection_1.resolver()
], OptionalParent);
return OptionalParent;
var OptionalParent_1;
}());
OptionalParent = OptionalParent_1 = tslib_1.__decorate([
aurelia_dependency_injection_1.resolver()
], OptionalParent);
exports_1("OptionalParent", OptionalParent);

@@ -36,0 +40,0 @@ }

@@ -0,0 +0,0 @@ import { FrameworkConfiguration } from 'aurelia-framework';

@@ -0,0 +0,0 @@ System.register(["aurelia-pal", "oribella", "./auto-scroll", "./optional-parent", "./sortable", "./utils"], function (exports_1, context_1) {

import { Repeat } from 'aurelia-templating-resources';
import { DefaultListenerArgs } from 'oribella';
import { DragClone } from './utils';
import { DragClone, Move } from './utils';
import { AutoScroll } from './auto-scroll';

@@ -26,3 +26,3 @@ export declare const SORTABLE = "oa-sortable";

axis: string;
onStop: () => void;
onStop: (move: Move) => void;
sortingClass: string;

@@ -54,2 +54,3 @@ dragClass: string;

private target;
private move;
constructor(element: Element, parentSortable: Sortable, autoScroll: AutoScroll);

@@ -56,0 +57,0 @@ activate(): void;

System.register(["tslib", "aurelia-pal", "aurelia-templating", "aurelia-templating-resources", "aurelia-dependency-injection", "oribella", "./optional-parent", "./utils", "./auto-scroll"], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var tslib_1, aurelia_pal_1, aurelia_templating_1, aurelia_templating_resources_1, aurelia_dependency_injection_1, oribella_1, optional_parent_1, utils_1, auto_scroll_1, SORTABLE, SORTABLE_ATTR, SORTABLE_ITEM, SORTABLE_ITEM_ATTR, Sortable, SortableItem, Sortable_1;
var tslib_1, aurelia_pal_1, aurelia_templating_1, aurelia_templating_resources_1, aurelia_dependency_injection_1, oribella_1, optional_parent_1, utils_1, auto_scroll_1, SORTABLE, SORTABLE_ATTR, SORTABLE_ITEM, SORTABLE_ITEM_ATTR, Sortable, SortableItem;
return {

@@ -40,4 +40,4 @@ setters: [

exports_1("SORTABLE_ITEM_ATTR", SORTABLE_ITEM_ATTR = "[" + SORTABLE_ITEM + "]");
Sortable = Sortable_1 = (function () {
function Sortable(element, parentSortable, autoScroll) {
Sortable = (function () {
var Sortable = Sortable_1 = function Sortable(element, parentSortable, autoScroll) {
var _this = this;

@@ -95,4 +95,5 @@ this.element = element;

this.childSortables = [];
this.move = utils_1.DefaultInvalidMove;
this.sortableDepth = utils_1.utils.getSortableDepth(this);
}
};
Sortable.prototype.activate = function () {

@@ -139,7 +140,7 @@ this.removeListener = oribella_1.oribella.on(oribella_1.Swipe, this.element, this);

var vm = utils_1.utils.getViewModel(element);
var moveFlag = utils_1.utils.move(this.dragClone, vm);
if (moveFlag === utils_1.MoveFlag.Valid) {
this.move = utils_1.utils.move(this.dragClone, vm);
if (this.move.flag === utils_1.MoveFlag.Valid) {
this.lastElementFromPointRect = element.getBoundingClientRect();
}
if (moveFlag === utils_1.MoveFlag.ValidNewList) {
if (this.move.flag === utils_1.MoveFlag.ValidNewList) {
this.lastElementFromPointRect = { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 };

@@ -173,2 +174,3 @@ }

var evt = _a.evt, client = _a.data.pointers[0].client, target = _a.target;
this.move = utils_1.DefaultInvalidMove;
if (!this.isClosestSortable(evt.target)) {

@@ -201,57 +203,59 @@ return oribella_1.RETURN_FLAG.REMOVE;

Sortable.prototype.stop = function () {
if (this.target)
if (this.target) {
this.target.classList.remove(this.sortingClass);
}
utils_1.utils.removeDragClone(this.dragClone);
this.autoScroll.deactivate();
this.childSortables.forEach(function (s) { return s.isDisabled = false; });
this.onStop();
this.onStop(this.move);
};
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "items", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scroll", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSpeed", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSensitivity", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "axis", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "onStop", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "sortingClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragZIndex", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "disallowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelector", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowDrag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "typeFlag", void 0);
Sortable = Sortable_1 = tslib_1.__decorate([
aurelia_templating_1.customAttribute(SORTABLE),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, optional_parent_1.OptionalParent.of(Sortable_1), auto_scroll_1.AutoScroll)
], Sortable);
return Sortable;
var Sortable_1;
}());
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "items", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scroll", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSpeed", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "scrollSensitivity", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "axis", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "onStop", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "sortingClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragClass", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "dragZIndex", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "disallowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelector", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowedDragSelectors", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "allowDrag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], Sortable.prototype, "typeFlag", void 0);
Sortable = Sortable_1 = tslib_1.__decorate([
aurelia_templating_1.customAttribute(SORTABLE),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, optional_parent_1.OptionalParent.of(Sortable_1), auto_scroll_1.AutoScroll)
], Sortable);
exports_1("Sortable", Sortable);

@@ -294,17 +298,17 @@ SortableItem = (function () {

});
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "item", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "typeFlag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "lockedFlag", void 0);
SortableItem = tslib_1.__decorate([
aurelia_templating_1.customAttribute(SORTABLE_ITEM),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, aurelia_templating_resources_1.Repeat)
], SortableItem);
return SortableItem;
}());
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "item", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "typeFlag", void 0);
tslib_1.__decorate([
aurelia_templating_1.bindable
], SortableItem.prototype, "lockedFlag", void 0);
SortableItem = tslib_1.__decorate([
aurelia_templating_1.customAttribute(SORTABLE_ITEM),
aurelia_dependency_injection_1.inject(aurelia_pal_1.DOM.Element, aurelia_templating_resources_1.Repeat)
], SortableItem);
exports_1("SortableItem", SortableItem);

@@ -311,0 +315,0 @@ }

@@ -34,2 +34,16 @@ import { Point } from 'oribella-framework';

}
export interface Move {
flag: MoveFlag;
fromItems: any[];
fromIndex: number;
toItems: any[];
toIndex: number;
}
export declare const DefaultInvalidMove: {
flag: MoveFlag;
fromItems: never[];
fromIndex: number;
toItems: never[];
toIndex: number;
};
export interface WindowDimension {

@@ -94,3 +108,3 @@ innerWidth: number;

getViewModel(element: SortableItemElement): SortableItem;
move(dragClone: DragClone, toVM: SortableItem): number;
move(dragClone: DragClone, toVM: SortableItem): Move;
pointInside({top, right, bottom, left}: Rect, {x, y}: Point): boolean;

@@ -97,0 +111,0 @@ elementFromPoint({x, y}: Point, selector: string, sortableElement: Element, dragClone: DragClone, axisFlag: AxisFlag): Element | null;

System.register(["oribella-framework", "./sortable"], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var oribella_framework_1, sortable_1, AxisFlag, LockedFlag, MoveFlag, utils;
var oribella_framework_1, sortable_1, AxisFlag, LockedFlag, MoveFlag, DefaultInvalidMove, utils;
return {

@@ -32,2 +32,3 @@ setters: [

exports_1("MoveFlag", MoveFlag);
exports_1("DefaultInvalidMove", DefaultInvalidMove = { flag: MoveFlag.Invalid, fromItems: [], fromIndex: -1, toItems: [], toIndex: -1 });
;

@@ -60,14 +61,14 @@ exports_1("utils", utils = {

if (!fromVM) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
if (typeof toVM.lockedFlag === 'number' && (toVM.lockedFlag & LockedFlag.To) !== 0) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
var fromSortable = fromVM.parentSortable;
if (!fromSortable) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
var toSortable = toVM.parentSortable;
if (!toSortable) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}

@@ -78,3 +79,3 @@ var fromItem = fromVM.item;

if (fromSortable.sortableDepth !== toVM.childSortable.sortableDepth) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}

@@ -85,21 +86,21 @@ toSortable = toVM.childSortable;

if (fromVM.parentSortable !== toSortable && (fromVM.typeFlag & toSortable.typeFlag) === 0) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
if (fromSortable.sortableDepth !== toSortable.sortableDepth) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
var fromItems = fromSortable.items;
var fromIx = fromItems.indexOf(fromItem);
var fromIndex = fromItems.indexOf(fromItem);
var toItems = toSortable.items;
var toIx = toItems.indexOf(toItem);
if (toIx === -1) {
toIx = 0;
var toIndex = toItems.indexOf(toItem);
if (toIndex === -1) {
toIndex = 0;
}
var removedFromItem = fromItems.splice(fromIx, 1)[0];
toItems.splice(toIx, 0, removedFromItem);
var removedFromItem = fromItems.splice(fromIndex, 1)[0];
toItems.splice(toIndex, 0, removedFromItem);
if (changedToSortable) {
fromVM.parentSortable = toSortable;
return MoveFlag.ValidNewList;
return { flag: MoveFlag.ValidNewList, fromItems: fromItems, fromIndex: fromIndex, toItems: toItems, toIndex: toIndex };
}
return MoveFlag.Valid;
return { flag: MoveFlag.Valid, fromItems: fromItems, fromIndex: fromIndex, toItems: toItems, toIndex: toIndex };
},

@@ -106,0 +107,0 @@ pointInside: function (_a, _b) {

{
"name": "oribella-aurelia-sortable",
"version": "0.12.0",
"version": "0.13.0-dev.20170717",
"description": "Aurelia Sortable plugin powered by Oribella",

@@ -62,2 +62,8 @@ "repository": {

"devDependencies": {
"@types/chai": "^4.0.1",
"@types/jsdom": "^11.0.1",
"@types/mocha": "^2.2.41",
"@types/node": "^8.0.10",
"@types/sinon": "^2.3.2",
"@types/sinon-chai": "^2.7.28",
"aurelia-bootstrapper": "^2.0.1",

@@ -64,0 +70,0 @@ "aurelia-framework": "^1.0.8",

@@ -5,2 +5,3 @@ import {resolver, Container} from 'aurelia-dependency-injection';

export class OptionalParent {
// tslint:disable-next-line:ban-types
constructor(private key: Function | string) {}

@@ -15,2 +16,3 @@

// tslint:disable-next-line:ban-types
public static of(key: Function | string) {

@@ -17,0 +19,0 @@ return new OptionalParent(key);

@@ -7,3 +7,3 @@ import { DOM } from 'aurelia-pal';

import { OptionalParent } from './optional-parent';
import { utils, SortableItemElement, SortableElement, DragClone, Rect, PageScrollOffset, AxisFlag, LockedFlag, MoveFlag } from './utils';
import { utils, SortableItemElement, SortableElement, DragClone, Rect, PageScrollOffset, AxisFlag, LockedFlag, MoveFlag, Move, DefaultInvalidMove } from './utils';
import { AutoScroll } from './auto-scroll';

@@ -33,3 +33,3 @@

@bindable public axis: string = AxisFlag.XY;
@bindable public onStop: () => void = () => { };
@bindable public onStop: (move: Move) => void = () => { };
@bindable public sortingClass: string = 'oa-sorting';

@@ -86,2 +86,3 @@ @bindable public dragClass: string = 'oa-drag';

private target: Element;
private move: Move = DefaultInvalidMove;

@@ -133,7 +134,7 @@ constructor(public element: Element, public parentSortable: Sortable, private autoScroll: AutoScroll) {

const vm = utils.getViewModel(element as SortableItemElement);
const moveFlag = utils.move(this.dragClone, vm);
if (moveFlag === MoveFlag.Valid) {
this.move = utils.move(this.dragClone, vm);
if (this.move.flag === MoveFlag.Valid) {
this.lastElementFromPointRect = element.getBoundingClientRect();
}
if (moveFlag === MoveFlag.ValidNewList) {
if (this.move.flag === MoveFlag.ValidNewList) {
this.lastElementFromPointRect = { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 };

@@ -165,2 +166,3 @@ }

public down({ evt, data: { pointers: [{ client }] }, target }: DefaultListenerArgs) {
this.move = DefaultInvalidMove;
if (!this.isClosestSortable(evt.target as Node)) {

@@ -191,7 +193,9 @@ return RETURN_FLAG.REMOVE;

public stop() {
if(this.target) this.target.classList.remove(this.sortingClass);
if (this.target) {
this.target.classList.remove(this.sortingClass);
}
utils.removeDragClone(this.dragClone);
this.autoScroll.deactivate();
this.childSortables.forEach((s) => s.isDisabled = false);
this.onStop();
this.onStop(this.move);
}

@@ -198,0 +202,0 @@ }

@@ -28,2 +28,12 @@ import { Point, matchesSelector } from 'oribella-framework';

export interface Move {
flag: MoveFlag;
fromItems: any[];
fromIndex: number;
toItems: any[];
toIndex: number;
}
export const DefaultInvalidMove = { flag: MoveFlag.Invalid, fromItems: [], fromIndex: -1, toItems: [], toIndex: -1 };
export interface WindowDimension {

@@ -115,18 +125,18 @@ innerWidth: number;

},
move(dragClone: DragClone, toVM: SortableItem): number {
move(dragClone: DragClone, toVM: SortableItem): Move {
let changedToSortable = false;
const fromVM = dragClone.viewModel;
if (!fromVM) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
if (typeof toVM.lockedFlag === 'number' && (toVM.lockedFlag & LockedFlag.To) !== 0) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
const fromSortable = fromVM.parentSortable;
if (!fromSortable) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
let toSortable = toVM.parentSortable;
if (!toSortable) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}

@@ -137,3 +147,3 @@ const fromItem = fromVM.item;

if (fromSortable.sortableDepth !== toVM.childSortable.sortableDepth) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}

@@ -144,21 +154,21 @@ toSortable = toVM.childSortable;

if (fromVM.parentSortable !== toSortable && (fromVM.typeFlag & toSortable.typeFlag) === 0) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
if (fromSortable.sortableDepth !== toSortable.sortableDepth) {
return MoveFlag.Invalid;
return DefaultInvalidMove;
}
const fromItems = fromSortable.items;
const fromIx = fromItems.indexOf(fromItem);
const fromIndex = fromItems.indexOf(fromItem);
const toItems = toSortable.items;
let toIx = toItems.indexOf(toItem);
if (toIx === -1) {
toIx = 0;
let toIndex = toItems.indexOf(toItem);
if (toIndex === -1) {
toIndex = 0;
}
const removedFromItem = fromItems.splice(fromIx, 1)[0];
toItems.splice(toIx, 0, removedFromItem);
const removedFromItem = fromItems.splice(fromIndex, 1)[0];
toItems.splice(toIndex, 0, removedFromItem);
if (changedToSortable) {
fromVM.parentSortable = toSortable;
return MoveFlag.ValidNewList;
return { flag: MoveFlag.ValidNewList, fromItems, fromIndex, toItems, toIndex };
}
return MoveFlag.Valid;
return { flag: MoveFlag.Valid, fromItems, fromIndex, toItems, toIndex };
},

@@ -165,0 +175,0 @@ pointInside({ top, right, bottom, left }: Rect, { x, y }: Point) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc