ShukantPal / pixi-essentials

The best goodies for performant, enterprise-level applications built on PixiJS
https://api.pixijs.io
MIT License
282 stars 36 forks source link

Transformer can't move with pixijs v7.2.x #92

Closed laochen closed 1 year ago

laochen commented 1 year ago

index.html `

CodePen - Inside PixiJS: @pixi-essentials/transformer

`

script.js `const app = new PIXI.Application({ width: 1024, height: 1024, autoDensity: true, resolution: window.devicePixelRatio || 1, view: document.getElementById("pen-canvas"), backgroundColor: 0xffffff, antialias: true }) app.stage.sortableChildren = true;

const transformer = app.stage.addChild(new PIXI.Transformer({ rotateEnabled: true, skewEnabled: true, boxRotationEnabled: true, group: [], stage: app.stage, wireframeStyle: { thickness: 1, color: 0xff0000 } }));

const circle = new PIXI.Graphics(); circle.beginFill(0xfedbac + 0x1f) .drawCircle(0, 0, 100) .endFill(); circle.pivot.set(50, 100); circle.scale.set(1); circle.position.set(300, 300);

const star = new PIXI.Graphics(); star.beginFill(0xfedbac + 0x1f) .drawStar(0, 0, 8, 100) .endFill(); star.position.set(800, 500); star.pivot.set(50, 100);

const starText = star.addChild(new PIXI.Text("Hello world!", { fontSize: 12 })); starText.x = -30;

const container = new PIXI.Container(); container.addChild(star); container.addChild(circle); container.eventMode = 'static'; container.interactive = true; container.on('pointerdown', onClick); app.stage.addChild(container);

function onClick(event) { console.log("clicked:" + event.target); if (transformer.group.length > 0) { let oldTarget = transformer.group.pop(); oldTarget.interactive = true; } transformer.group.push(event.target); transformer.zIndex = event.target.zIndex; event.target.interactive = false; }`

In index.html
change line 11

to

Changed this line, the object can be dragged normally

laochen commented 1 year ago

add these lines fix this app.stage.interactive = true; app.stage.eventMode = 'static';

ShukantPal commented 1 year ago

Thank you, I've updated the CodePen.