@@ -347,6 +347,19 @@ module.exports.draw = function (text, id) {
347
347
svgDraw . insertArrowHead ( diagram ) ;
348
348
svgDraw . insertArrowCrossHead ( diagram ) ;
349
349
350
+ function activeEnd ( msg , verticalPos ) {
351
+ var activationData = exports . bounds . endActivation ( msg ) ;
352
+ if ( activationData . starty + 18 > verticalPos ) {
353
+ activationData . starty = verticalPos - 6 ;
354
+ verticalPos += 12 ;
355
+ }
356
+ svgDraw . drawActivation ( diagram , activationData , verticalPos , conf ) ;
357
+
358
+ exports . bounds . insert ( activationData . startx , verticalPos - 10 , activationData . stopx , verticalPos ) ;
359
+ }
360
+
361
+ var lastMsg ;
362
+
350
363
// Draw the messages/signals
351
364
messages . forEach ( function ( msg ) {
352
365
var loopData ;
@@ -374,15 +387,10 @@ module.exports.draw = function (text, id) {
374
387
}
375
388
break ;
376
389
case sq . yy . LINETYPE . ACTIVE_START :
377
- // exports.bounds.bumpVerticalPos(conf.boxMargin);
378
390
exports . bounds . newActivation ( msg , diagram ) ;
379
- // exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin);
380
391
break ;
381
392
case sq . yy . LINETYPE . ACTIVE_END :
382
- var activationData = exports . bounds . endActivation ( msg ) ;
383
- svgDraw . drawActivation ( diagram , activationData , exports . bounds . getVerticalPos ( ) , conf ) ;
384
-
385
- exports . bounds . insert ( activationData . startx , exports . bounds . getVerticalPos ( ) - 10 , activationData . stopx , exports . bounds . getVerticalPos ( ) ) ;
393
+ activeEnd ( msg , exports . bounds . getVerticalPos ( ) ) ;
386
394
break ;
387
395
case sq . yy . LINETYPE . LOOP_START :
388
396
exports . bounds . bumpVerticalPos ( conf . boxMargin ) ;
@@ -426,14 +434,19 @@ module.exports.draw = function (text, id) {
426
434
break ;
427
435
default :
428
436
try {
437
+ lastMsg = msg ;
429
438
exports . bounds . bumpVerticalPos ( conf . messageMargin ) ;
430
439
var fromBounds = actorFlowVerticaBounds ( msg . from ) ;
431
440
var toBounds = actorFlowVerticaBounds ( msg . to ) ;
432
- var forward = fromBounds [ 0 ] < toBounds [ 0 ] ;
433
- startx = fromBounds [ forward ?1 :0 ] ;
434
- stopx = toBounds [ forward ?0 :1 ] ;
435
-
436
- drawMessage ( diagram , startx , stopx , exports . bounds . getVerticalPos ( ) , msg ) ;
441
+ var fromIdx = fromBounds [ 0 ] <= toBounds [ 0 ] ?1 :0 ;
442
+ var toIdx = fromBounds [ 0 ] < toBounds [ 0 ] ?0 :1 ;
443
+ startx = fromBounds [ fromIdx ] ;
444
+ stopx = toBounds [ toIdx ] ;
445
+
446
+ var verticalPos = exports . bounds . getVerticalPos ( ) ;
447
+ drawMessage ( diagram , startx , stopx , verticalPos , msg ) ;
448
+ var allBounds = fromBounds . concat ( toBounds ) ;
449
+ exports . bounds . insert ( Math . min . apply ( null , allBounds ) , verticalPos , Math . max . apply ( null , allBounds ) , verticalPos ) ;
437
450
} catch ( e ) {
438
451
console . error ( 'error while drawing message' , e ) ;
439
452
}
0 commit comments