diff --git a/angular-tree-control.js b/angular-tree-control.js index e3bd034..5cecf41 100644 --- a/angular-tree-control.js +++ b/angular-tree-control.js @@ -2,7 +2,7 @@ 'use strict'; angular.module( 'treeControl', [] ) - .directive( 'treecontrol', ['$compile', function( $compile ) { + .directive( 'treecontrol', ['$compile', '$timeout', function( $compile, $timeout) { /** * @param cssClass - the css class * @param addClassProperty - should we wrap the class name with class="" @@ -90,6 +90,9 @@ ensureDefault($scope.options.injectClasses, "labelSelected", ""); ensureDefault($scope.options, "equality", defaultEquality); ensureDefault($scope.options, "isLeaf", defaultIsLeaf); + ensureDefault($scope.options, "enableIntervalToggle", false); + ensureDefault($scope.options, "childrenLimitInterval", 10); + ensureDefault($scope.options, "childrenTimeInterval", 10); $scope.selectedNodes = $scope.selectedNodes || []; $scope.expandedNodes = $scope.expandedNodes || []; @@ -202,11 +205,25 @@ return isThisNodeSelected?"tree-selected" + injectSelectionClass:""; }; + $scope.enableIntervalToggleOnScope = function(scope){ + var limitInterval = $scope.options.childrenLimitInterval*1; + var timeInterval = $scope.options.childrenTimeInterval*1; + + scope.childrenLimit = limitInterval; + $timeout(function addChildren(){ + if(scope.childrenLimit < (scope.node.children || []).length){ + scope.childrenLimit = scope.childrenLimit + limitInterval; + $timeout(addChildren, timeInterval); + } + }, timeInterval); + }; + //tree template var orderBy = $scope.orderBy ? ' | orderBy:orderBy:reverseOrder' : ''; + var limitTo = $scope.options.enableIntervalToggle ? ' | limitTo:childrenLimit' : ''; var template = '