         self.setNeedsLayout()
         self.layoutIfNeeded()
         
+        
         switch self.direction {
             
         case .bottom, .bottomLeft, .bottomRight:
-            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: superview, attribute: .bottom, multiplier: 1, constant:  triangleSpacing - (self.bounds.height / 2) ))
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: origin, attribute: .bottom, multiplier: 1, constant:  triangleSpacing ))
             break
             
         case .top, .topRight, .topLeft:
-            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .bottom, relatedBy: .equal, toItem: superview, attribute: .top, multiplier: 1, constant:  (triangleSpacing - (self.bounds.height / 2)) * -1))
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .bottom, relatedBy: .equal, toItem: origin, attribute: .top, multiplier: 1, constant:  -triangleSpacing))
             break
             
         case .left, .right:
-            superview.addConstraint(NSLayoutConstraint(item: superview, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant:  0))
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .centerY, relatedBy: .equal, toItem: origin, attribute: .centerY, multiplier: 1, constant:  0))
             break
         }
         
         switch self.direction {
         case .left:
-            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .right, relatedBy: .equal, toItem: superview, attribute: .left, multiplier: 1, constant: (triangleSpacing - (self.bounds.width / 2)) * -1))
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .right, relatedBy: .equal, toItem: origin, attribute: .left, multiplier: 1, constant: -triangleSpacing))
             break
         case .bottomRight, .topRight:
-            self.superview?.addConstraint(NSLayoutConstraint(item: superview, attribute: .right, relatedBy: .equal, toItem: self, attribute: .right, multiplier: 1, constant:  ((self.bounds.width / 2)) * -1))
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .right, relatedBy: .equal, toItem: origin, attribute: .right, multiplier: 1, constant: 0))
             break
         case .bottomLeft, .topLeft:
-            self.superview?.addConstraint(NSLayoutConstraint(item: superview, attribute: .left, relatedBy: .equal, toItem: self, attribute: .left, multiplier: 1, constant:  ((self.bounds.width / 2))))
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .left, relatedBy: .equal, toItem: origin, attribute: .left, multiplier: 1, constant: 0))
             break
         case .right:
-            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .left, relatedBy: .equal, toItem: superview, attribute: .right, multiplier: 1, constant:  triangleSpacing - (self.bounds.width / 2) ))
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .left, relatedBy: .equal, toItem: origin, attribute: .right, multiplier: 1, constant:  triangleSpacing ))
             break
         case .top, .bottom:
-            self.superview?.addConstraint(NSLayoutConstraint(item: superview, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1, constant:  0))
-            break
-        }
+            superview.addConstraint(NSLayoutConstraint(item: self, attribute: .centerX, relatedBy: .equal, toItem: origin, attribute: .centerX, multiplier: 1, constant:  0))
+            break
+        }
+    
         
         if (animationEnable) {
             

    }
    
    
    fileprivate func displayInView(_ superview:UIView) {
        
        superview.addSubview(self)
        
        self.layoutMargins = UIEdgeInsetsMake(8, 13, 8, 13)
        self.layer.cornerRadius = 4
        
        switch self.direction {
        case .left:
            self.layer.anchorPoint = CGPoint(x: 1, y: 0.5)
            break
        case .right:
            self.layer.anchorPoint = CGPoint(x: 0, y: 0.5)
            break
        case .bottom:
            self.layer.anchorPoint = CGPoint(x: 0.5, y: 0)
            break
        case .top:
            self.layer.anchorPoint = CGPoint(x: 0.5, y: 1)
            break
        case .topLeft:
            self.layer.anchorPoint = CGPoint(x: 0, y: 1)
            break
        case .topRight:
            self.layer.anchorPoint = CGPoint(x: 1, y: 1)
            break
        case .bottomLeft:
            self.layer.anchorPoint = CGPoint(x: 0, y: 0)
            break
        case .bottomRight:
            self.layer.anchorPoint = CGPoint(x: 1, y: 0)
            break
        }
        
        triangleShapeLayer?.removeFromSuperlayer()
        

    
    public func showTooltip() {
        if tooltipView?.isVisible == false {
            tooltipView?.displayInView(tooltipDisplayView ?? self, origin: self)
        }
    }
    
