forked from jdittrich/quickMockup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
second attempt on containment logic using StrongComposite
- Loading branch information
1 parent
1a7c82d
commit a6e9c0c
Showing
8 changed files
with
139 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 67 additions & 37 deletions
104
dist/libqmock-f9d9d4e1044c6d17783e.js → dist/libqmock-52ed7d8dac60fff9f68a.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import draw2d from '@sarhanalaa/draw2d' | ||
|
||
/** | ||
* | ||
*/ | ||
const Container = draw2d.shape.composite.StrongComposite.extend({ | ||
assignFigure: function (figure) { | ||
this.assignedFigures.add(figure) | ||
figure.setComposite(this) | ||
return this | ||
}, | ||
|
||
unassignFigure: function (figure) { | ||
this.assignedFigures.remove(figure) | ||
figure.setComposite(null) | ||
return this | ||
}, | ||
|
||
onDragLeave: function(figure) { | ||
this.unassignFigure(figure) | ||
}, | ||
|
||
onCatch: function (droppedFigure, x, y, shiftKey, ctrlKey) { | ||
if (droppedFigure.getComposite()) { | ||
return | ||
} | ||
|
||
if (this.getBoundingBox().contains(droppedFigure.getBoundingBox())) { | ||
this.assignFigure(droppedFigure) | ||
} | ||
}, | ||
|
||
setPosition: function (x, y) { | ||
let oldX = this.x | ||
let oldY = this.y | ||
|
||
this._super(x, y) | ||
|
||
let dx = this.x - oldX | ||
let dy = this.y - oldY | ||
|
||
if (dx === 0 && dy === 0) { | ||
return this | ||
} | ||
|
||
this.assignedFigures.each(function (i, figure) { | ||
figure.translate(dx, dy) | ||
}) | ||
|
||
return this | ||
}, | ||
|
||
toFront: function(figure) { | ||
this._super(figure) | ||
} | ||
|
||
}) | ||
|
||
export default Container |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters