Skip to content

Commit

Permalink
project build
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobscarter committed Sep 12, 2016
1 parent b7ad39e commit 5545e5e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 20 deletions.
72 changes: 54 additions & 18 deletions dist/angular-ui-tree.js
@@ -1,5 +1,5 @@
/**
* @license Angular UI Tree v2.20.0
* @license Angular UI Tree v2.21.0
* (c) 2010-2016. https://github.com/angular-ui-tree/angular-ui-tree
* License: MIT
*/
Expand Down Expand Up @@ -604,6 +604,7 @@
placeElm,
hiddenPlaceElm,
dragElm,
scrollContainerElm,
treeScope = null,
elements, // As a parameter for callbacks
dragDelaying = true,
Expand Down Expand Up @@ -643,6 +644,7 @@

scope.collapsed = !!UiTreeHelper.getNodeAttribute(scope, 'collapsed') || treeConfig.defaultCollapsed;
scope.expandOnHover = !!UiTreeHelper.getNodeAttribute(scope, 'expandOnHover');
scope.scrollContainer = UiTreeHelper.getNodeAttribute(scope, 'scrollContainer') || attrs.scrollContainer || null;
scope.sourceOnly = scope.nodropEnabled || scope.$treeScope.nodropEnabled;

scope.$watch(attrs.collapsed, function (val) {
Expand All @@ -668,6 +670,18 @@
attrs.$set('expandOnHover', val);
});

attrs.$observe('scrollContainer', function(val) {
if ((typeof val) === 'string') {
scope.scrollContainer = val;
}
});

scope.$watch('scrollContainer', function(val) {
UiTreeHelper.setNodeAttribute(scope, 'scrollContainer', val);
attrs.$set('scrollContainer', val);
scrollContainerElm = document.querySelector(val);
});

scope.$on('angular-ui-tree:collapse-all', function () {
scope.collapsed = true;
});
Expand All @@ -678,7 +692,7 @@

/**
* Called when the user has grabbed a node and started dragging it.
*
*
* @param {MouseEvent} e event that is triggered by DOM.
* @return undefined?
*/
Expand Down Expand Up @@ -865,6 +879,7 @@
topElmPos,
top_scroll,
bottom_scroll,
scrollContainerElmRect,
target,
decrease,
targetX,
Expand All @@ -874,6 +889,7 @@
targetElm,
isEmpty,
scrollDownBy,
scrollUpBy,
targetOffset,
targetBefore;

Expand Down Expand Up @@ -918,19 +934,39 @@
'top': topElmPos + 'px'
});

//Getting position to top and bottom of page.
top_scroll = window.pageYOffset || $window.document.documentElement.scrollTop;
bottom_scroll = top_scroll + (window.innerHeight || $window.document.clientHeight || $window.document.clientHeight);
if (scrollContainerElm) {
//Getting position to top and bottom of container element.
scrollContainerElmRect = scrollContainerElm.getBoundingClientRect();
top_scroll = scrollContainerElm.scrollTop;
bottom_scroll = top_scroll + scrollContainerElm.clientHeight;

//To scroll down if cursor y-position is greater than the bottom position the vertical scroll
if (bottom_scroll < eventObj.pageY && bottom_scroll < document_height) {
scrollDownBy = Math.min(document_height - bottom_scroll, 10);
window.scrollBy(0, scrollDownBy);
}
//To scroll down if cursor y-position is greater than the bottom position of the container vertical scroll
if (scrollContainerElmRect.bottom < eventObj.clientY && bottom_scroll < scrollContainerElm.scrollHeight) {
scrollDownBy = Math.min(scrollContainerElm.scrollHeight - bottom_scroll, 10);
scrollContainerElm.scrollTop += scrollDownBy;
}

//To scroll top if cursor y-position is less than the top position of the container vertical scroll
if (scrollContainerElmRect.top > eventObj.clientY && top_scroll > 0) {
scrollUpBy = Math.min(top_scroll, 10);
scrollContainerElm.scrollTop -= scrollUpBy;
}
} else {
//Getting position to top and bottom of page.
top_scroll = window.pageYOffset || $window.document.documentElement.scrollTop;
bottom_scroll = top_scroll + (window.innerHeight || $window.document.clientHeight || $window.document.clientHeight);

//To scroll down if cursor y-position is greater than the bottom position of the window vertical scroll
if (bottom_scroll < eventObj.pageY && bottom_scroll < document_height) {
scrollDownBy = Math.min(document_height - bottom_scroll, 10);
window.scrollBy(0, scrollDownBy);
}

//To scroll top if cursor y-position is less than the top position the vertical scroll
if (top_scroll > eventObj.pageY) {
window.scrollBy(0, -10);
//To scroll top if cursor y-position is less than the top position of the window vertical scroll
if (top_scroll > eventObj.pageY) {
scrollUpBy = Math.min(top_scroll, 10);
window.scrollBy(0, -scrollUpBy);
}
}

//Calling service to update position coordinates based on move.
Expand Down Expand Up @@ -1168,20 +1204,20 @@

//TODO(jcarter): Is dragStart need to be unbound?
unbindDragMoveEvents();

//This cancel the collapse/expand login running.
$timeout.cancel(scope.expandTimeout);

scope.$treeScope.$apply(function () {
$q.when(scope.$treeScope.$callbacks.beforeDrop(dragEventArgs))

//Promise resolved (or callback didn't return false)
.then(function (allowDrop) {
if (allowDrop !== false && scope.$$allowNodeDrop && !outOfBounds) {

//Node drop accepted.
dragInfo.apply();

//Fire the dropped callback only if the move was successful.
scope.$treeScope.$callbacks.dropped(dragEventArgs);
} else {
Expand All @@ -1190,7 +1226,7 @@
bindDragStartEvents();
}
})

//Promise rejected - revert the node to its original position.
.catch(function () {
bindDragStartEvents();
Expand Down Expand Up @@ -1257,7 +1293,7 @@
}
};
})();

keydownHandler = function (e) {
if (e.keyCode === 27) {
dragEndEvent(e);
Expand Down

0 comments on commit 5545e5e

Please sign in to comment.