question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Click events not scrolling with the view?

See original GitHub issue

I have noticed that when using this scrollbox, the visuals in the container are moving but the click “hitboxes” are not.

Below is a modified example from davidfig where I have reduced the content height to force vertical scrolling:

function test()
{
    let scrollbox = new Scrollbox.Scrollbox({
        boxWidth: 550,
        boxHeight: 100
    });
    _renderer.stage.addChild(scrollbox);

    // insert element
    let tableStringContainer = new PIXI.Container(),
        hitArea = new PIXI.Graphics();

    // just added some colors and circles so I can see the scrollbox and target
    hitArea.beginFill(0xff0000).drawCircle(0, 0, 100).endFill()
    hitArea.beginFill(0xff0000, 1);
    hitArea.drawRect(0, 0, 540, 35);
    hitArea.endFill()
    hitArea.interactive = true;
    hitArea.buttonMode = true;

    hitArea
        .on('click', function ()
        {
            console.log('click');
        })
        .on('mouseover', function ()
        {
            console.log('mouseover');
        })
        .on('mouseout', function ()
        {
            console.log('mouseout');
        });
    tableStringContainer.addChild(hitArea);
    scrollbox.content.addChild(tableStringContainer);

    scrollbox.update();
}

window.onload = function ()
{
    _renderer = new PIXI.Application({ transparent: true, width: window.innerWidth, height: window.innerHeight, resolution: window.devicePixelRatio })
    document.body.appendChild(_renderer.view)
    _renderer.view.style.position = 'fixed'
    _renderer.view.style.width = '100vw'
    _renderer.view.style.height = '100vh'
    _renderer.view.style.left = 0
    _renderer.view.style.top = 0
test()
return

    horizontalVertical()
    vertical()
    horizontal()
    const nodrag = horizontalVertical('dragScroll=false (drag scrollbars to move)')
    nodrag.position.set(400, 425)
    nodrag.dragScroll = false
    window.addEventListener('resize', resize)

}

For me, the click events on the circle area are persisting on the left side of the screen, even when the circle is scrolled out of view.

Thanks

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
davidfigcommented, Nov 19, 2019

Ok, I fixed this bug. You need to update pixi-scrollbox and pixi-viewport from npm.

The bug was caused by pixi-viewport.plugins.clamp(). pixi.js’s interaction module does not handle containers that move (ie, if the container’s position is changing, then it won’t register an interaction–which is a weird omission). The viewport.plugins.clamp was improperly changing the position of the viewport (to the same clamped position) each frame even if nothing needed changing.

Let me know if there are any problems with this fix.

0reactions
davidfigcommented, Apr 2, 2020

Can you create a jsfiddle so I can play with it and find the problem? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Click event not firing with overflow: scroll
I've built a page with a fixed header at the top of the view that contains a horizontally scrollable set of tabs with...
Read more >
Document: scroll event - Web APIs - MDN Web Docs - Mozilla
The scroll event fires when the document view has been scrolled. To detect when scrolling has completed, see the Document: scrollend event.
Read more >
JavaScript Scroll Events, Event Throttling & Passive Events
In this tutorial, you will learn about the JavaScript scroll events and how to handle scroll event properly.
Read more >
Scroll Events and Intersection Observer - Beginner JavaScript
Either of them work in this case because a scroll event does not bubble like a regular click would. So if you scroll...
Read more >
[Solved] Scroll not working when elements inside have click ...
So, the solution, avoid using Event Trigger, instead, implement the interface you need for the purpose. My example, instead of adding ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found