2

When I drag a stage, stage moves only x-axis.

But konva.js docs doesn't have explanation about it..

Just modify Konva.js sources about drag and i use it?

Or I missed something?

JunHyeok
  • 81
  • 4

2 Answers2

6

I've found it..

var stage = new Konva.Stage({
        container: 'container',
        width: window.innerWidth,
        height: window.innerHeight,
        draggable: true,
        dragBoundFunc: (pos) => {
            return {
                x : pos.x,
                y : 0
            }
        }
    });

it's done.

JunHyeok
  • 81
  • 4
1

The two drag bounds examples explain how to constrain the movement of a draggable element.

Simple Drag Bounds Tutorial

Complex Drag and Drop Bounds

As you have found this approach can be used on the stage.

kevgathuku
  • 316
  • 5
  • 16
Vanquished Wombat
  • 9,075
  • 5
  • 28
  • 67