首页 > 解决方案 > How can I drag stage only x axis in Konva.js

问题描述

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?

标签: konvajs

解决方案


我已经找到了。。

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

完成。


推荐阅读