xieziyu / angular2-draggable

Angular directive (for version >= 2.x ) that makes the DOM element draggable and resizable
https://xieziyu.github.io/angular2-draggable/
294 stars 103 forks source link

Item is produced with div partially out of bounds #97

Closed wdunn001 closed 5 years ago

wdunn001 commented 6 years ago

I am unsure if perhaps I am doing something wrong. I have a div element which has a component inside of it.

.bubble-wrapper {
  position: absolute;
  display: inline-block;
  z-index: 100;
  width: 280px;
  .bubble-header {
    cursor: move;
    font: 400 14px/20px Roboto, "Helvetica Neue", sans-serif;
    display: flex;
    box-sizing: border-box;
    padding: 0 8px;
    width: 100%;
    flex-direction: row;
    align-items: center;
    white-space: nowrap;
    background-color: $primary;
    * {
      color: #FFF
    }
    .bubble-title {
      line-height: normal;
    }
  }
}
<div *ngFor="let bubble of infoBubblesShown;" class="bubble-wrapper"
  ngDraggable [bounds]="element" [inBounds]="true" [trackPosition]="true" [position]="{x: bubble.x, y: bubble.y}" (mouseenter)="cancelCloseObserver()"
  (mouseleave)="removeInfoBubbleObserver(bubble.id)" [handle]="bubbleHandle">
  <div class="bubble-header" #bubbleHandle>
    <div class="bubble-title">
        <h4 style="margin: 0;">{{bubble.name}}</h4>
        <sub *ngIf="bubble.driver.length > 0 && bubble.driver != bubble.name">Driver: {{bubble.driver}}</sub>
    </div>

      <span class="spacer"></span>
        <button mat-icon-button>
            <mat-icon class="pinned" [class.pinned]='bubble.pinned' (click)="bubble.pinned = !bubble.pinned">attachment</mat-icon>
          </button>
          <button mat-icon-button>
            <mat-icon (click)="bubble.pinned = false; removeBubble(bubble.id);">close</mat-icon>
          </button>

  </div>
  <custom-component></custom-component>
</div>

The problem is if the position at which the draggable item appears is sometimes partially outside the bounds of the parent div. as soon as it is clicked on it adjusts to being in bounds. Is there something I am doing wrong that is allowing the draggable div to appear out of bounds? here is an image showing what I am seeing.

example

xieziyu commented 6 years ago

@wdunn001 It should be a bug of ngDraggable itself. Thanks for reporting this issue. I will double check it.

xieziyu commented 6 years ago

It should be fixed in v2.1.2.

wdunn001 commented 6 years ago

AweSome! you rock!