Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demo/scripts/controllers/KanbanController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ angular.module('demoApp').controller('KanbanController', ['$scope', 'BoardServic
},
orderChanged: function (event) {
},
containment: '#board'
containment: '#board',
allowOverflow: true
};

$scope.removeCard = function (column, card) {
Expand Down
36 changes: 22 additions & 14 deletions dist/ng-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
* @param containerPositioning - absolute or relative positioning.
* @param {Object} [scrollableContainer] (optional) Scrollable container object
*/
movePosition: function (event, element, pos, container, containerPositioning, scrollableContainer) {
movePosition: function (event, element, pos, container, containerPositioning, scrollableContainer, allowOverflow) {
var bounds;
var useRelative = (containerPositioning === 'relative');

Expand All @@ -227,15 +227,17 @@
bounds.top = 0;
}

if (element.x < bounds.left) {
element.x = bounds.left;
} else if (element.x >= bounds.width + bounds.left - this.offset(element).width) {
element.x = bounds.width + bounds.left - this.offset(element).width;
}
if (element.y < bounds.top) {
element.y = bounds.top;
} else if (element.y >= bounds.height + bounds.top - this.offset(element).height) {
element.y = bounds.height + bounds.top - this.offset(element).height;
if(!allowOverflow){
if (element.x < bounds.left) {
element.x = bounds.left;
} else if (element.x >= bounds.width + bounds.left - this.offset(element).width) {
element.x = bounds.width + bounds.left - this.offset(element).width;
}
if (element.y < bounds.top) {
element.y = bounds.top;
} else if (element.y >= bounds.height + bounds.top - this.offset(element).height) {
element.y = bounds.height + bounds.top - this.offset(element).height;
}
}
}

Expand All @@ -258,7 +260,6 @@
* moveTo: moveTo, isSameParent: isSameParent, isOrderChanged: isOrderChanged, eventArgs: eventArgs, apply: apply}}
*/
dragItem: function (item) {

return {
index: item.index(),
parent: item.sortableScope,
Expand Down Expand Up @@ -629,7 +630,8 @@
isPlaceHolderPresent,//is placeholder present.
isDisabled = false, // drag enabled
escapeListen, // escape listen event
isLongTouch = false; //long touch disabled.
isLongTouch = false, //long touch disabled.
allowOverflow; //allow dragged element to overflow containment

hasTouch = 'ontouchstart' in $window;
isIOS = /iPad|iPhone|iPod/.test($window.navigator.userAgent) && !$window.MSStream;
Expand Down Expand Up @@ -659,6 +661,10 @@
}
});

scope.index = function () {
return scope.itemScope.$index;
};

scope.$on('$destroy', function () {
angular.element($document[0].body).unbind('keydown', escapeListen);
});
Expand Down Expand Up @@ -796,8 +802,10 @@
dragElement.append(scope.itemScope.element);
}

allowOverflow = !!scope.sortableScope.options.allowOverflow;

containment.append(dragElement);
$helper.movePosition(eventObj, dragElement, itemPosition, containment, containerPositioning, scrollableContainer);
$helper.movePosition(eventObj, dragElement, itemPosition, containment, containerPositioning, scrollableContainer, allowOverflow);

scope.sortableScope.$apply(function () {
scope.callbacks.dragStart(dragItemInfo.eventArgs());
Expand Down Expand Up @@ -904,7 +912,7 @@
targetElement = angular.element($document[0].elementFromPoint(targetX, targetY));
dragElement.removeClass(sortableConfig.hiddenClass);

$helper.movePosition(eventObj, dragElement, itemPosition, containment, containerPositioning, scrollableContainer);
$helper.movePosition(eventObj, dragElement, itemPosition, containment, containerPositioning, scrollableContainer, allowOverflow);

//Set Class as dragging starts
dragElement.addClass(sortableConfig.dragging);
Expand Down
Loading