Refactoring to not render connectors for a Regexp with one Match
This commit is contained in:
		
							parent
							
								
									fe6727b79a
								
							
						
					
					
						commit
						6a9d498bf6
					
				@ -18,7 +18,8 @@ export default _.extend({}, Base, {
 | 
				
			|||||||
        positions,
 | 
					        positions,
 | 
				
			||||||
        container = this.container,
 | 
					        container = this.container,
 | 
				
			||||||
        totalHeight,
 | 
					        totalHeight,
 | 
				
			||||||
        verticalCenter;
 | 
					        verticalCenter,
 | 
				
			||||||
 | 
					        includeLines = (this.matches().length > 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _.invoke(this.matches(), 'position');
 | 
					    _.invoke(this.matches(), 'position');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -32,33 +33,35 @@ export default _.extend({}, Base, {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    totalHeight = positions.reduce((offset, pos) => {
 | 
					    totalHeight = positions.reduce((offset, pos) => {
 | 
				
			||||||
      pos.content.transform(Snap.matrix()
 | 
					      pos.content.transform(Snap.matrix()
 | 
				
			||||||
        .translate(center - pos.box.cx + 20, offset));
 | 
					        .translate(center - pos.box.cx + (includeLines ? 20 : 0), offset));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return offset + pos.box.height + 5;
 | 
					      return offset + pos.box.height + 5;
 | 
				
			||||||
    }, 0).value() - 5;
 | 
					    }, 0).value() - 5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    verticalCenter = totalHeight / 2
 | 
					    verticalCenter = totalHeight / 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    positions.each(pos => {
 | 
					    if (includeLines) {
 | 
				
			||||||
      var box = pos.content.getBBox(),
 | 
					      positions.each(pos => {
 | 
				
			||||||
          direction = box.cy > verticalCenter ? 1 : -1,
 | 
					        var box = pos.content.getBBox(),
 | 
				
			||||||
          pathStr,
 | 
					            direction = box.cy > verticalCenter ? 1 : -1,
 | 
				
			||||||
          path;
 | 
					            pathStr,
 | 
				
			||||||
 | 
					            path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      pathStr = (verticalCenter === box.cy) ?
 | 
					        pathStr = (verticalCenter === box.cy) ?
 | 
				
			||||||
        'M0,{center}H{side}' :
 | 
					          'M0,{center}H{side}' :
 | 
				
			||||||
        'M0,{center}q10,0 10,{d}V{target}q0,{d} 10,{d}H{side}';
 | 
					          'M0,{center}q10,0 10,{d}V{target}q0,{d} 10,{d}H{side}';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      path = container.path(Snap.format(pathStr, {
 | 
					        path = container.path(Snap.format(pathStr, {
 | 
				
			||||||
        center: verticalCenter,
 | 
					          center: verticalCenter,
 | 
				
			||||||
        target: box.cy - 10 * direction,
 | 
					          target: box.cy - 10 * direction,
 | 
				
			||||||
        side: box.x,
 | 
					          side: box.x,
 | 
				
			||||||
        d: 10 * direction
 | 
					          d: 10 * direction
 | 
				
			||||||
      }));
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      path.clone().transform(Snap.matrix()
 | 
					        path.clone().transform(Snap.matrix()
 | 
				
			||||||
        .scale(-1, 1, center + 20, 0));
 | 
					          .scale(-1, 1, center + 20, 0));
 | 
				
			||||||
    });
 | 
					      });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  matches() {
 | 
					  matches() {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user