我一直在尝试按照 Kinetic API 上的教程将滚动条放入我的 KineticJS 应用程序中。我让滚动条本身按其应有的方式显示,但我不确定如何使用事件监听器来实际移动舞台或每个层,以便滚动条实际移动 View 。
var hscrollArea = new Kinetic.Rect({
x: 10,
y: $(window).height() - 30 - 80, // 80 to account for the fixed footer
width: $(window).width() - 40,
height: 20,
fill: "gray",
opacity: 0.3
});
var hscroll = new Kinetic.Rect({
x: 10,
y: $(window).height() - 30 - 80,// 80 to account for the fixed footer
width: 130,
height: 20,
fill: "orange",
draggable: true,
dragBoundFunc: function(pos) {
// TODO: Move stage or layers at this point
console.log("dragBoundFunc: " + this);
return {
x: pos.x,
y: this.getAbsolutePostion().y
};
},
opacity: 0.9,
stroke: "black",
strokeWidth: 1
});
var vscrollArea = new Kinetic.Rect({
x: $(window).width() - 30,
y: 10,
width: 20,
height: $(window).height() - 40 - 80,
fill: "gray",
opacity: 0.3
});
var vscroll = new Kinetic.Rect({
x: $(window).width() - 30,
y: 10,
width: 20,
height: 70,
fill: "orange",
draggable: true,
dragBoundFunc: function(pos) {
// TODO: Move stage or layers at this point
console.log("dragBoundFunc: " + this);
return {
x: this.getAbsolutePosition().x,
y: pos.y
};
},
opacity: 0.9,
stroke: "black",
strokeWidth: 1
});
任何帮助将不胜感激:) 谢谢, 贝基
最佳答案
拖动滚动条(矩形)时,您可以移动舞台或图层。即,
stage.move(50,50);
stage.draw();
stage.move(-50,-50);
stage.draw();
关于javascript - 用于滚动的 KineticJS 变换层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15133130/