Skip to content

Commit

Permalink
Release v2.1.5
Browse files Browse the repository at this point in the history
Bugfix: EndOffset event not working properly with SnapToGrid
  • Loading branch information
Xie, Ziyu committed Oct 15, 2018
1 parent 12b081a commit e189d26
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ angular2-draggable has angular directives that make the DOM element draggable an

# Latest Update

+ 2018.10.15: 2.1.5
+ **ngDraggable**: fix [issue #114](https://github.com/xieziyu/angular2-draggable/issues/114): EndOffset event not working properly with SnapToGrid

+ 2018.09.17: 2.1.4
+ Fix a build issue.
+ **ngResizable**: fix [issue #100](https://github.com/xieziyu/angular2-draggable/issues/100): Resize bounds on a draggable element inside a containment is off
Expand Down
2 changes: 1 addition & 1 deletion projects/angular2-draggable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular2-draggable",
"version": "2.1.4",
"version": "2.1.5",
"author": "Xie, Ziyu",
"license": "MIT",
"keywords": [
Expand Down
21 changes: 13 additions & 8 deletions projects/angular2-draggable/src/lib/angular-draggable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class AngularDraggableDirective implements OnInit, OnDestroy, OnChanges,
private orignal: Position = null;
private oldTrans = new Position(0, 0);
private tempTrans = new Position(0, 0);
private currTrans = new Position(0, 0);
private oldZIndex = '';
private _zIndex = '';
private needTransform = false;
Expand Down Expand Up @@ -111,6 +112,7 @@ export class AngularDraggableDirective implements OnInit, OnDestroy, OnChanges,
this.orignal = null;
this.oldTrans = null;
this.tempTrans = null;
this.currTrans = null;
this._helperBlock.dispose();
this._helperBlock = null;
}
Expand Down Expand Up @@ -161,10 +163,7 @@ export class AngularDraggableDirective implements OnInit, OnDestroy, OnChanges,
this.edge.emit(this.boundsCheck());
}

this.movingOffset.emit({
x: this.tempTrans.x + this.oldTrans.x,
y: this.tempTrans.y + this.oldTrans.y
});
this.movingOffset.emit(this.currTrans.value);
}
}

Expand All @@ -190,6 +189,10 @@ export class AngularDraggableDirective implements OnInit, OnDestroy, OnChanges,
this.renderer.setStyle(this.el.nativeElement, '-ms-transform', value);
this.renderer.setStyle(this.el.nativeElement, '-moz-transform', value);
this.renderer.setStyle(this.el.nativeElement, '-o-transform', value);

// save current position
this.currTrans.x = translateX;
this.currTrans.y = translateY;
}

private pickUp() {
Expand Down Expand Up @@ -245,6 +248,11 @@ export class AngularDraggableDirective implements OnInit, OnDestroy, OnChanges,
}
}

/** Get current offset */
getCurrentOffset() {
return this.currTrans.value;
}

private putBack() {
if (this._zIndex) {
this.renderer.setStyle(this.el.nativeElement, 'z-index', this._zIndex);
Expand Down Expand Up @@ -278,10 +286,7 @@ export class AngularDraggableDirective implements OnInit, OnDestroy, OnChanges,
}

this.moving = false;
this.endOffset.emit({
x: this.tempTrans.x + this.oldTrans.x,
y: this.tempTrans.y + this.oldTrans.y
});
this.endOffset.emit(this.currTrans.value);

if (this.trackPosition) {
this.oldTrans.add(this.tempTrans);
Expand Down
4 changes: 4 additions & 0 deletions projects/angular2-draggable/src/lib/models/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class Position implements IPosition {
return new Position(0, 0).set(p);
}

get value(): IPosition {
return { x: this.x, y: this.y };
}

add(p: IPosition) {
this.x += p.x;
this.y += p.y;
Expand Down
7 changes: 7 additions & 0 deletions src/assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.1.5 (2018-10-15)

#### Bugfix
+ **ngDraggable**: EndOffset event not working properly with SnapToGrid. [#114](https://github.com/xieziyu/angular2-draggable/issues/114)

---

## 2.1.4 (2018-09-17)

#### Bugfix
Expand Down

0 comments on commit e189d26

Please sign in to comment.