mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 17:21:36 +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) {
|
if(node) {
|
||||||
var pos = that.getUserPosition();
|
var pos = that.getUserPosition();
|
||||||
var db = node.attrs.dragBounds;
|
|
||||||
var dbf = node.attrs.dragBoundFunc;
|
var dbf = node.attrs.dragBoundFunc;
|
||||||
|
var db = node.attrs.dragBounds;
|
||||||
var dc = node.attrs.dragConstraint;
|
var dc = node.attrs.dragConstraint;
|
||||||
var lastNodePos = {
|
var lastNodePos = {
|
||||||
x: node.attrs.x,
|
x: node.attrs.x,
|
||||||
@@ -799,6 +799,11 @@ Kinetic.Stage = Kinetic.Container.extend({
|
|||||||
y: pos.y - go.drag.offset.y
|
y: pos.y - go.drag.offset.y
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(dbf !== undefined) {
|
||||||
|
// execute nodes dragBoundFunc if defined
|
||||||
|
newNodePos = dbf.call(node, newNodePos, evt);
|
||||||
|
}
|
||||||
|
|
||||||
// bounds overrides
|
// bounds overrides
|
||||||
if(db.left !== undefined && newNodePos.x < db.left) {
|
if(db.left !== undefined && newNodePos.x < db.left) {
|
||||||
newNodePos.x = db.left;
|
newNodePos.x = db.left;
|
||||||
@@ -813,11 +818,6 @@ Kinetic.Stage = Kinetic.Container.extend({
|
|||||||
newNodePos.y = db.bottom;
|
newNodePos.y = db.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dbf !== undefined) {
|
|
||||||
// execute dragBoundFunc if defined
|
|
||||||
newNodePos = dbf.call(node, newNodePos, evt);
|
|
||||||
}
|
|
||||||
|
|
||||||
// constraint overrides
|
// constraint overrides
|
||||||
if(dc === 'horizontal') {
|
if(dc === 'horizontal') {
|
||||||
newNodePos.y = lastNodePos.y;
|
newNodePos.y = lastNodePos.y;
|
||||||
@@ -826,7 +826,6 @@ Kinetic.Stage = Kinetic.Container.extend({
|
|||||||
newNodePos.x = lastNodePos.x;
|
newNodePos.x = lastNodePos.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
node.setAbsolutePosition(newNodePos);
|
node.setAbsolutePosition(newNodePos);
|
||||||
|
|
||||||
if(!go.drag.moving) {
|
if(!go.drag.moving) {
|
||||||
|
|||||||
Reference in New Issue
Block a user