davidfig / pixi-viewport

A highly configurable viewport/2D camera designed to work with pixi.js
https://davidfig.github.io/pixi-viewport/
MIT License
1.04k stars 174 forks source link

The mobile terminal cannot be moved or zoomed after three fingers click #401

Closed jialongsu closed 1 year ago

jialongsu commented 1 year ago

"pixi-viewport": "^4.35.1", "pixi.js": "^6.5.4",

100% repetition

davidfig commented 1 year ago

Not sure what that means. maybe provide a video?

jialongsu commented 1 year ago

https://user-images.githubusercontent.com/17847087/194978606-66419490-063e-4922-a0f7-d4e912af8acf.mp4

import * as PIXI from 'pixi.js' import { Viewport } from 'pixi-viewport'

// or with require // const PIXI = require('pixi.js') // const Viewport = require('pixi-viewport').Viewport

const app = new PIXI.Application() document.body.appendChild(app.view)

// create viewport const viewport = new Viewport({ screenWidth: window.innerWidth, screenHeight: window.innerHeight, worldWidth: 1000, worldHeight: 1000,

interaction: app.renderer.plugins.interaction // the interaction module is important for wheel to work properly when renderer.view is placed or scaled

})

// add the viewport to the stage app.stage.addChild(viewport)

// activate plugins viewport .drag() .pinch() .wheel() .decelerate()

// add a red box const sprite = viewport.addChild(new PIXI.Sprite(PIXI.Texture.WHITE)) sprite.tint = 0xff0000 sprite.width = sprite.height = 100 sprite.position.set(100, 100)

davidfig commented 1 year ago

There's probably a bug in InputManager.ts. My guess is that the count() function is not properly decremented when multiple touch points are released in a pointerup event (although, I'm not sure how that works). It would have to be debugged. I'd add a console.log(event) on line 171 of InputManager.ts to see how many pointerup events are called and what they look like.

jialongsu commented 1 year ago

Finding the same issue as this issue and using the same resolution method can resolve the problem. https://github.com/davidfig/pixi-viewport/issues/364

fix code:

viewport.on('drag-end', () => { app.renderer.plugins.interaction.interactionDataPool = []; });