@@ -97,7 +97,12 @@ var View = /** @class */ (function () {
9797 highlightNode ( index , color ) ;
9898 } ;
9999 } ( index , color ) ;
100- manager . addEvent ( new FrontendEvent ( forward , forward , this . animSpeed ) ) ;
100+ var backward = function ( index ) {
101+ return function ( ) {
102+ removeHighlight ( index ) ;
103+ } ;
104+ } ( index ) ;
105+ manager . addEvent ( new FrontendEvent ( forward , backward , this . animSpeed ) ) ;
101106 } ;
102107 View . prototype . highlightThisSortElem = function ( index , color ) {
103108 var forward = function ( index , color ) {
@@ -108,11 +113,24 @@ var View = /** @class */ (function () {
108113 manager . addEvent ( new FrontendEvent ( forward , forward , this . animSpeed ) ) ;
109114 } ;
110115 View . prototype . removeThisHighlight = function ( index ) {
116+ // Find the current color
117+ var color = "" ;
118+ var classList = document . getElementById ( 'arrayElem' + index ) . className . split ( / \s + / ) ;
119+ for ( var i = 0 ; i < classList . length ; i ++ ) {
120+ if ( classList [ i ] === 'orange' || classList [ i ] === 'green' ) {
121+ color = classList [ i ] ;
122+ }
123+ }
111124 var forward = function ( index ) {
112125 return function ( ) {
113126 removeHighlight ( index ) ;
114127 } ;
115128 } ( index ) ;
129+ var backward = function ( index , color ) {
130+ return function ( ) {
131+ highlightNode ( index , color ) ;
132+ } ;
133+ } ( index , color ) ;
116134 manager . addEvent ( new FrontendEvent ( forward , forward , this . animSpeed ) ) ;
117135 } ;
118136 View . prototype . setThisState = function ( relationships , backendArray ) {
@@ -122,7 +140,10 @@ var View = /** @class */ (function () {
122140 this . step ( "backward" , twoDimRelationshipsJSON , backendArray ) ;
123141 } ;
124142 View . prototype . stepForward = function ( twoDimRelationshipsJSON , backendArray ) {
125- this . step ( "forward" , twoDimRelationshipsJSON , backendArray ) ;
143+ //this.step("forward", twoDimRelationshipsJSON, backendArray);
144+ manager . next ( ) ;
145+ if ( manager . nextEvents . length <= 0 )
146+ manager . start ( ) ;
126147 } ;
127148 View . prototype . step = function ( dir , twoDimRelationshipsJSON , backendArray ) {
128149 var relationships = JSON . parse ( twoDimRelationshipsJSON ) ;
@@ -161,7 +182,12 @@ var View = /** @class */ (function () {
161182 screenLock ( lock ) ;
162183 } ;
163184 } ( locked ) ;
164- manager . addEvent ( new FrontendEvent ( lck , lck , this . animSpeed ) ) ;
185+ var notLck = function ( lock ) {
186+ return function ( ) {
187+ screenLock ( ! lock ) ;
188+ } ;
189+ } ( locked ) ;
190+ manager . addEvent ( new FrontendEvent ( lck , notLck , this . animSpeed ) ) ;
165191 } ;
166192 View . prototype . setSlow = function ( ) {
167193 this . animSpeed = 250 ;
@@ -294,14 +320,20 @@ var View = /** @class */ (function () {
294320 View . prototype . insertNewElemThis = function ( child , value , parent ) {
295321 var forward = function ( index , value , parent ) {
296322 return function ( ) {
297- insertNewElem ( index , value ) ;
323+ setValueAtIndex ( index , value ) ;
324+ insertNewNode ( index , value ) ;
298325 insertNewElemConnect ( index , parent ) ;
326+ // If first node -> Position with a nice animation
327+ if ( control . getAlgorithm ( ) . getArrayLength ( ) == 1 )
328+ positioningNodes ( 1500 ) ;
299329 } ;
300330 } ( child , value , parent ) ;
301331 var backward = function ( index , parent ) {
302332 return function ( ) {
303333 allNodes [ parent ] . removeChild ( allNodes [ index ] ) ;
304- removeElem ( index , true ) ;
334+ //removeElem(index, true);
335+ setValueAtIndex ( index , "" ) ;
336+ removeNode ( index ) ;
305337 } ;
306338 } ( child , parent ) ;
307339 manager . addEvent ( new FrontendEvent ( forward , backward , manager . delayTime ) ) ;
0 commit comments