mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
It's better to applie the custom dragBoundFunc before applying 'normal' dragBounds och dragConstraints so they wont get overridden.
This commit is contained in:
13
src/Stage.js
13
src/Stage.js
@@ -785,8 +785,8 @@ Kinetic.Stage = Kinetic.Container.extend({
|
||||
|
||||
if(node) {
|
||||
var pos = that.getUserPosition();
|
||||
var db = node.attrs.dragBounds;
|
||||
var dbf = node.attrs.dragBoundFunc;
|
||||
var db = node.attrs.dragBounds;
|
||||
var dc = node.attrs.dragConstraint;
|
||||
var lastNodePos = {
|
||||
x: node.attrs.x,
|
||||
@@ -799,6 +799,11 @@ Kinetic.Stage = Kinetic.Container.extend({
|
||||
y: pos.y - go.drag.offset.y
|
||||
};
|
||||
|
||||
if(dbf !== undefined) {
|
||||
// execute nodes dragBoundFunc if defined
|
||||
newNodePos = dbf.call(node, newNodePos, evt);
|
||||
}
|
||||
|
||||
// bounds overrides
|
||||
if(db.left !== undefined && newNodePos.x < db.left) {
|
||||
newNodePos.x = db.left;
|
||||
@@ -813,11 +818,6 @@ Kinetic.Stage = Kinetic.Container.extend({
|
||||
newNodePos.y = db.bottom;
|
||||
}
|
||||
|
||||
if(dbf !== undefined) {
|
||||
// execute dragBoundFunc if defined
|
||||
newNodePos = dbf.call(node, newNodePos, evt);
|
||||
}
|
||||
|
||||
// constraint overrides
|
||||
if(dc === 'horizontal') {
|
||||
newNodePos.y = lastNodePos.y;
|
||||
@@ -826,7 +826,6 @@ Kinetic.Stage = Kinetic.Container.extend({
|
||||
newNodePos.x = lastNodePos.x;
|
||||
}
|
||||
|
||||
|
||||
node.setAbsolutePosition(newNodePos);
|
||||
|
||||
if(!go.drag.moving) {
|
||||
|
Reference in New Issue
Block a user