我尝试实现一个简单的平移和缩放相机,因此想更改PIXI容器的光标样式。
我发现从鼠标事件处理程序更改舞台的光标样式确实可以,而在尝试对其他任何容器执行相同操作时却无效。
第一个代码段可以正确更改光标,而第二个代码段则不能。拜托,有人能告诉我我在做什么错吗?
const app = new PIXI.Application({width: 500, height: 500});
document.getElementById('canvasWrapper').appendChild(app.view);
app.stage.interactive = true;
app.stage.hitArea = new PIXI.Rectangle(0, 0, 500, 500)
app.stage.cursor = 'grab';
app.stage.on('pointerdown', event => app.stage.cursor = 'grabbing');
app.stage.on('pointermove', event => console.log('dragging'));
app.stage.on('pointerup', event => app.stage.cursor = 'grab');
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.8.2/pixi.min.js"></script>
<div id='canvasWrapper' />
const app = new PIXI.Application({width: 500, height: 500});
document.getElementById('canvasWrapper').appendChild(app.view);
const container = new PIXI.Container();
app.stage.addChild(container);
container.interactive = true;
container.hitArea = new PIXI.Rectangle(0, 0, 500, 500)
container.cursor = 'grab';
container.on('pointerdown', event => app.stage.cursor = 'grabbing');
container.on('pointermove', event => console.log('dragging'));
container.on('pointerup', event => app.stage.cursor = 'grab');
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.8.2/pixi.min.js"></script>
<div id='canvasWrapper' />