Skip to content

Commit 29447a1

Browse files
author
Xie, Ziyu
committed
Release v2.1.3
Bugfix: issue #100
1 parent 707c335 commit 29447a1

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ angular2-draggable has angular directives that make the DOM element draggable an
2727
+ provided since v2.0, requires Angular >= 6
2828

2929
# Latest Update
30+
+ 2018.09.14: 2.1.3
31+
+ **ngResizable**: fix [issue #100](https://github.com/xieziyu/angular2-draggable/issues/100): Resize bounds on a draggable element inside a containment is off
32+
3033
+ 2018.08.20: 2.1.2
3134
+ **ngDraggable**: fix [issue #97](https://github.com/xieziyu/angular2-draggable/issues/97): Item is produced with div partially out of bounds.
3235

@@ -134,6 +137,7 @@ Well you can use both directives concurrently if you wish:
134137
| outOfBounds | `{ top: boolean; bottom: boolean; right: boolean; left: boolean }` | `false` | Set it to allow element get out of bounds from the direction. Refer to [demo](https://xieziyu.github.io/angular2-draggable/#/usage/boundary) |
135138
| position | `{ x: number, y: number }` | `{ x:0, y:0 }` | Use it to set position offset |
136139
| gridSize | number | 1 | Use it for snapping to grid. Refer to [demo](https://xieziyu.github.io/angular2-draggable/#/advance/snap-grid) |
140+
| preventDefaultEvent | boolean | `false` | Whether to prevent default mouse event |
137141

138142
+ `ngResizable` directive support following input porperties:
139143

projects/angular2-draggable/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-draggable",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"author": "Xie, Ziyu",
55
"license": "MIT",
66
"keywords": [

projects/angular2-draggable/src/lib/angular-resizable.directive.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,17 +423,17 @@ export class AngularResizableDirective implements OnInit, OnChanges, OnDestroy,
423423

424424
private checkBounds() {
425425
if (this._containment) {
426-
const maxWidth = this._bounding.width - this._bounding.pr - this.el.nativeElement.offsetLeft;
427-
const maxHeight = this._bounding.height - this._bounding.pb - this.el.nativeElement.offsetTop;
426+
const maxWidth = this._bounding.width - this._bounding.pr - this.el.nativeElement.offsetLeft - this._bounding.translateX;
427+
const maxHeight = this._bounding.height - this._bounding.pb - this.el.nativeElement.offsetTop - this._bounding.translateY;
428428

429-
if (this._direction.n && this._currPos.y < 0) {
430-
this._currPos.y = 0;
431-
this._currSize.height = this._origSize.height + this._origPos.y;
429+
if (this._direction.n && (this._currPos.y + this._bounding.translateY) < 0) {
430+
this._currPos.y = -this._bounding.translateY;
431+
this._currSize.height = this._origSize.height + this._origPos.y + this._bounding.translateY;
432432
}
433433

434-
if (this._direction.w && this._currPos.x < 0) {
435-
this._currPos.x = 0;
436-
this._currSize.width = this._origSize.width + this._origPos.x;
434+
if (this._direction.w && (this._currPos.x + this._bounding.translateX) < 0) {
435+
this._currPos.x = -this._bounding.translateX;
436+
this._currSize.width = this._origSize.width + this._origPos.x + this._bounding.translateX;
437437
}
438438

439439
if (this._currSize.width > maxWidth) {
@@ -489,11 +489,23 @@ export class AngularResizableDirective implements OnInit, OnChanges, OnDestroy,
489489
if (computed) {
490490
let p = computed.getPropertyValue('position');
491491

492+
const nativeEl = window.getComputedStyle(this.el.nativeElement);
493+
let transforms = nativeEl.getPropertyValue('transform').replace(/[^-\d,]/g, '').split(',');
494+
492495
this._bounding = {};
493496
this._bounding.width = el.clientWidth;
494497
this._bounding.height = el.clientHeight;
495498
this._bounding.pr = parseInt(computed.getPropertyValue('padding-right'), 10);
496499
this._bounding.pb = parseInt(computed.getPropertyValue('padding-bottom'), 10);
500+
501+
if (transforms.length >= 6) {
502+
this._bounding.translateX = parseInt(transforms[4], 10);
503+
this._bounding.translateY = parseInt(transforms[5], 10);
504+
} else {
505+
this._bounding.translateX = 0;
506+
this._bounding.translateY = 0;
507+
}
508+
497509
this._bounding.position = computed.getPropertyValue('position');
498510

499511
if (p === 'static') {

projects/angular2-draggable/src/scss/resizable.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
}
7878

7979
.ng-resizable-diagonal {
80+
box-sizing: border-box;
8081
width: 0;
8182
height: 0;
8283
border-bottom: $handle-corner-size solid #aaa;

src/assets/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.1.3 (2018-09-14)
2+
3+
#### Bugfix
4+
+ **ngResizable**: Resize bounds on a draggable element inside a containment is off. [#100](https://github.com/xieziyu/angular2-draggable/issues/100)
5+
6+
---
7+
18
## 2.1.2 (2018-08-20)
29

310
#### Bugfix

0 commit comments

Comments
 (0)