Ngl: Auto scrolling up and down

Created on 8 Aug 2018  路  6Comments  路  Source: nglviewer/ngl

Hey there. It looks like when I am scrolling down a page and then I click again into the div which contains de NGL, the page automatically scrolls up/down to the center of the figure.

Sometimes this behavior is annoying. Is there a way to disable it?

question

Most helpful comment

I have found a workaround: the HTML for the canvas ahas a tabindex set to -1 which should prevent the canvas to be focusable. But this is not efficient in Chrome and programatically removing the tabindex does the job: stage.viewer.renderer.domElement.removeAttribute('tabindex')

All 6 comments

@arose I have created an example at https://codepen.io/pen?template=JNLMXb
In order to reproduce what I said, please scroll down until the footer, click there and then click in any black space. You should see the browser scrolling automatically trying to center the NGL view.

https://codepen.io/biharck/pen/bjOgPK

It looks like that this bug just happens on Google Chrome.

Could you please, help me?

Thanks a lot.

@arose would you mind to help me with that, please?

This is something vendor specific in my experience (happens in chrome + safari but does not happen in firefox). I am wondering if it is not a "feature" of this browser when a webGL context gets the focus.
If I trigger the focus programatically (stage.viewer.renderer.domElement.focus()) I observe the same auto scrolling of the canvas into view.
I have tried to add a focus event listener to the canvas to prevent default behaviour without any success regarding this issue.

I have found a workaround: the HTML for the canvas ahas a tabindex set to -1 which should prevent the canvas to be focusable. But this is not efficient in Chrome and programatically removing the tabindex does the job: stage.viewer.renderer.domElement.removeAttribute('tabindex')

thanks @ppillot!

Thank you @ppillot :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefdoerr picture stefdoerr  路  3Comments

sbliven picture sbliven  路  3Comments

thomashopf picture thomashopf  路  6Comments

sunhwan picture sunhwan  路  4Comments

ghost picture ghost  路  4Comments