pixi-viewport
pixi-viewport copied to clipboard
mouseup and mousedown event types missing?
Edit: Hmm, maybe I'm mistaken here. I tried downgrading again but the errors are still there.
Might be the fact that I upgraded typescript to 4.1.5 from 3.7. Dunno why I'm getting all these error because of that though..
I updated my pixi-viewport package from 4.13.2 to 4.20.1 and ran in to this error:
Argument of type '"mousedown"' is not assignable to parameter of type '"moved"'. TS2769
407 | this.viewport.on('moved', throttle(movedHandler, 500))
408 | this.viewport.on('moved-end', this.moveEndHandler.bind(this))
> 409 | this.viewport.on('mousedown', mouseDownHandler)
| ^
410 | this.viewport.on('mousemove', mouseMoveHandler)
411 | this.viewport.on('touchmove', mouseMoveHandler)
412 | this.viewport.on('mouseup', mouseUpHandler)
It seems like mousedown, mouseup was removed and replaced by clicked.
I wasn't expecting breaking changes but I think the update of types to fit with pixi v6 broke some stuff for me.
Also having some trouble when I try to pass the viewport object to my stage:
this.app.stage.addChild(viewport)
Types of property 'on' are incompatible.
[1] Type '{ (event: "added" | "removed", fn: (container: Container) => void, context?: any): Viewport; (event: InteractionEvent, fn: (event: InteractionEvent) => void, context?: any): Viewport; (event: EventType, fn: (viewport: Viewport) => void, context?: any): Viewport; (event: ClickEventType, fn: (data: ClickEventData) => ...' is not assignable to type '{ (event: InteractionEventTypes, fn: (event: InteractionEvent) => void, context?: any): DisplayObject; (event: string | symbol, fn: Function, context?: any): DisplayObject; }'.
[1] Types of parameters 'fn' and 'fn' are incompatible.
[1] Types of parameters 'event' and 'container' are incompatible.
[1] Type 'Container' is missing the following properties from type 'InteractionEvent': stopped, target, currentTarget, type, and 3 more.
I'll try updating to pixi v6 and fix any compatibility issues, but I wanted to share this to notify you that this is (or might be classified as(?)) a breaking change.
Also, I'm guessing I'm gonna have some trouble with my mouseup and mousedown functions since they seem to have merged to a single clicked event. Any tips on that?
Hmm...yup, it's likely caused by my fix to the types for v6. I don't normally use typescript, so if you could suggest a change to the types that would work for both pixi v5 and v6, I'll add it (or merge it if you want to roll a PR). I removed a few of the listener types b/c of a conflict with v6, btw.
The mouseup/mousedown/clicked events should all be there. The mouseup/mousedown is a pixi event, and clicked is an additional viewport event.