I am using this library to scroll the page at certain points in my app. Everything was working well until I added this line that should happen at the same time as the page scroll.
this.myInput.first.nativeElement.focus()
This caused the focus() to race the page scroll. Since I am giving the page scroll call a pageScrollDuration and the focus() apparently scrolls with a duration of 0, the page jumps to the input instead of smoothly scrolling there.
How do I make sure the page scroll smoothly scrolls to the element while still focusing on it?
The solution I was able to find was to wrap the
this.myInput.first.nativeElement.focus()
with the following:
setTimeout(() => {
this.myInput.first.nativeElement.focus()
}, 0)
This causes the page scroll to happen smoothly.
Related
I have a big page therefore I cannot paste the whole code here. But the problem is clear and briefly like this: There are animations on the page. On every page refresh, visible area scrolls a bit down. The framework I use is react js. I used below code but it doesn't scroll to top most, it leaves a little space. And on each page refresh the gap increases.
useEffect(()=>{
window.scrollTo({top: 0, left: 0, behavior: 'smooth' })
}, [])
Only hard refreshing the page starts without any gap. Is there a different way to have a try? Any help?
My Ionic1 app displays a list of items that can be collapsed/expanded, so the vertical length of the content can increase significantly when an element is expanded (the way I do it is through ng-show directives).
My issue is that when this happens, I cannot scroll down to see the new content. Actually, if I drag my finger from bottom to top, I can see the new content appear in the bottom, but as soon as I release my finger, some elasticity brings back the top of the content.
However, strangely enough, after a few seconds, the scrolling mechanics is updated correctly and I can scroll normally.
It looks like the Ionic framework takes some time to figure out that the content length has changed and needs some update in the scrolling mechanics... I would like to tell him immediately once it is needed. I tried to call $apply from the onClick call back of the Expand buttons, but I get an error saying I am already in a digest cycle.
Any clue to fix this please? Many thanks!
You can avoid $apply approach because every $scope.$apply is rebind in the page. So you can follow the ionic scroll concept.
ionic scroll
Thanks! this helped me fix the problem, by adding a call to $ionicScrollDelegate.resize() whenever some item is collapsed/expanded.
You can check the issue with this fiddle: quickly expand groups 7/8/9 and try to scroll down:
http://jsfiddle.net/shengoo/6b0y3tar/
I have a website using enjin.com website builder, and I have a page where you can go to play my game that is a .swf, but its html form, and the game requires mouse scrolling for some features and when I test it, the page also moves up and down, how can I disable mouse scrolling only on that specific page? I want the scroll bar on right of screen to still function as it does regularly though, so users can scroll if they really need to.
You can use this css property:
pointer-events:none
For more detail: https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
In my GWT application I use a DialogBox like this:
DialogBox dialog = new DialogBox(autoHide, true);
dialog.setText("Hello GWT DialogBox");
dialog.setGlassEnabled(true);
dialog.center();
dialog.show();
My whole page is very long and it scrolls vertically.
This works fine, the dialog pops up and the rest of the page is darkened. When scrolling (with mouse wheel) outside the dialog box nothing happens, which is fine. But when scrolling inside of the dialog box, the whole page scrolls away including the dialog box itself. This feels very wrong.
It is even possible to use scrolling inside the dialog box to scroll the dialog box out of the visible area and then there is no way to scroll it back, because scrolling outside of the dialog box does not do anything.
How to prevent the page from scrolling when using the mouse wheel inside the dialog box?
dialog.setModal(true);
might work. This discards all the events that do not affect the DialogBox, aka scroll that is affecting the underlying page.
WAIT NEVER MIND, DOESN'T WORK
The Page will still scroll if the mouse is within the DialogBox.
Found this though:
https://www.mail-archive.com/google-web-toolkit#googlegroups.com/msg62527.html
Might be useful.
I don't know why, but when my page loads, i get scrolled in the middle, but i don't have any anchor aiming on this point...
Now i have to put a <a href='MY-URL#top'></a> anchor in every page for not getting scrolled on the middle...(Firefox don't even get them :0, -webkit browsers do...)
I have many anchor aiming on id's, and a JQuery script for smooth scrolling, but no one for the middle scrolling of pages on load.
You can see that here :
http://www.groupae.be/ediser/2.0/nos_produits.php
What would fire that scrolling on load?
If the page is long enough to have scroll and if you set focus on some element (for example for accessibility features), browser scrolls page in such way that focused element is in the middle of the screen (if scrolls allows to do it, if not it will be scrolled as far as possible).
its ok i found why i was getting scrolled, just the autofocus in the footer form... :/