Drag not working on example
See original GitHub issueHey, I noticed that in the example provided in the repo’s README dragging doesn’t work even though the viewport.drag() is being called, is it supposed to be like that? How could this code be modified to allow dragging?
import * as PIXI from 'pixi.js'
import { Viewport } from 'pixi-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)
Thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
basic drag and drop examples not working on rails
I'm reading the files on the client using javascript, get some info, and then make an ajax call. All that works when using...
Read more >Drag and drop/click and drag stops working temporarily ...
Hello, I've been having this weird problem with the touchpad of my new HP Envy Windows 10 system. My ability to click-and-drag stops...
Read more >File drag and drop - Web APIs | MDN
This example illustrates the use of both APIs (and does not use any Gecko specific interfaces). Define the drop zone. The target element...
Read more >Click and Drag Not Working with Touchpad | Articles
But if using a touchpad, you may need a bit more finger-work. Click+drag (Example: scrollbars)¶. Click and hold the left touchpad button. Run...
Read more >Drag'n'Drop with mouse events
In the examples above the ball is always moved so that its center is ... The problem is that, while we're dragging, the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I had the same issue in a project which combines ReactJS and PIXIjs.
The problem turned out to be related to a
z-inde
x set on the div that contains the canvas generated by PIXI. Once I removed the pan/drag got restored.In my project, the code looked like this (the
div
in the render is where PIXIjs operates).I figured it out because I remembered I had the same issue with a d3js generated SVG which I wanted to zoom and pan. To me this indicates the
z-index
property may generally affects pointer events behavior, probably in relation to which other elements are there in the page. However it looks weird to me that only the drag was broken, while the scroll-wheel zoom and the pinch zoom did not present any issues.Good find. The wheel uses a separate event that attaches to
document
(I think). So that makes sense. If you’re talking about the trackpad pinch then that also makes sense for the same reason. If you’re talking about the touchscreen pinch then I agree that does not make sense since it uses the same event listeners as the drag.