Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CDK-8.0.0-beta][Drag&Drop] set new position isn't working #15765

Closed
MDzyga opened this issue Apr 9, 2019 · 1 comment · Fixed by #15805
Closed

[CDK-8.0.0-beta][Drag&Drop] set new position isn't working #15765

MDzyga opened this issue Apr 9, 2019 · 1 comment · Fixed by #15805
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@MDzyga
Copy link

MDzyga commented Apr 9, 2019

What is the expected behavior?

Set new position using new version of SDK.

What is the current behavior?

Nothing happened.
Drag Drop

What are the steps to reproduce?

My HTML looks like:

<div class="background-image"
   [ngStyle]="getBackground()">
<img #layout="cdkDrag"
    cdkDragBoundary=".background-image"
    cdkDrag
    (cdkDragEnded)="dragMoved()"
    [cdkDragFreeDragPosition]="currentPosition"
    class="qr-code-image"
    [style.width.px]="qrCodeWidth"
    src="{{baseUrl}}images/qr-code.png"
    alt="QR Code">
</div>
     ....
      <mat-form-field>
        <input #positionX
               matInput
               placeholder="Position X"
               type="number"
               min="0"
               [max]="maxPositionX"
               matTooltip="Move from left"
               [ngModel]="qrCodeImage.qrCodeX"
               (ngModelChange)="changePosition($event, 'qrCodeX')"
               name="qrCodeX">
      </mat-form-field>

      <mat-form-field>
        <input #positionY
               matInput
               placeholder="Position Y"
               type="number"
               min="0"
               [max]="maxPositionY"
               matTooltip="Move from top"
               [ngModel]="qrCodeImage.qrCodeY"
               (ngModelChange)="changePosition($event, 'qrCodeY')"
               name="qrCodeY">
      </mat-form-field>

In my typescript file I have below method to set X and Y position

changePosition(positionValue: number, changedPropertyName: string) {
    this.qrCodeImage[changedPropertyName] = positionValue;

    this.currentPosition = { x: this.qrCodeImage.qrCodeX, y: this.qrCodeImage.qrCodeY };
}

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

"@angular/animations": "^7.2.12",
"@angular/cdk": "^8.0.0-beta.0",
"@angular/common": "^7.2.12",
"@angular/compiler": "^7.2.12",
"@angular/core": "^7.2.12",
"@angular/forms": "^7.2.12",
"@angular/material": "^8.0.0-beta.0",
"@angular/platform-browser": "^7.2.12",
"@angular/platform-browser-dynamic": "^7.2.12",
"typescript": "~3.2.4",

Is there anything else we should know?

When I change image's initial size, drag & drop "thinks" that image have old size. Because of it I can move some part of it out of the area.

@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Apr 12, 2019
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 12, 2019
Fixes the `CdkDrag` not reacting to changes in the `cdkDragFreeDragPosition` input, because we had mispelled something and it wasn't caught by TS since `SimpleChanges` isn't typed.

Fixes angular#15765.
mmalerba pushed a commit that referenced this issue Apr 23, 2019
#15805)

Fixes the `CdkDrag` not reacting to changes in the `cdkDragFreeDragPosition` input, because we had mispelled something and it wasn't caught by TS since `SimpleChanges` isn't typed.

Fixes #15765.
RudolfFrederiksen pushed a commit to RudolfFrederiksen/material2 that referenced this issue Jun 21, 2019
angular#15805)

Fixes the `CdkDrag` not reacting to changes in the `cdkDragFreeDragPosition` input, because we had mispelled something and it wasn't caught by TS since `SimpleChanges` isn't typed.

Fixes angular#15765.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants