Anchor scroll after page loaded for the first time
caneta opened this issue · 4 comments
On a Liferay 7 DXP fixpack 31, I have the following problem:
on my website I have an header with position fixed of 200px and when I cut and paste an url like http://mywebsite.com#myanchor I get that the anchor is displayed at the top of the page but uder the header.
I would like to scroll it down 200px, in order to see properly the anchor, but I'm not able to catch an event in order to do that.
In other words, I'm able to do that after a endNavigate
event with
Liferay.SPA.app.on('endNavigate', function () {
window.scrollTo(0, 200)
}); // on endNavigate event
But it doesn't work if I load a page for the first time (Liferay.on('SPAReady', function(){})
do not work either).
THis does not work if I put the url with cut and paste in browser address field or even if I click on the link http://mywebsite.com#myanchor from an external resource, for example an email.
How to perform a scroll in this case? Which event have I to use?
Thank you.
Probably I would like to have an event like already described on issue #140
At the moment I cannot run anything after that senna reaches the anchor level, and I need it to perform a further scroll in order to pass over my fixed header.
Any workaround suggested?
Hey @caneta,
Sorry for the delay, can you see if the endNavigate
event is called? passing some console.log
to check. Thanks!
No, the endNavigate
event is not fired at page load, this is the problem depicted in #140 too.
We're about to archive this repo and mark it as read-only. As explained here the Senna code base has been ingested into Liferay DXP itself in the form of the frontend-js-spa-web
module, and we have migrated the v2.x history over into the liferay-frontend-projects monorepo so that we can keep our stuff together (and have uniform testing, linting, building etc) and will cut any necessary maintenance releases from there.
So as to clean out stale issues, I am closing anything that hasn't had any activity in the last year. If this is still relevant, would you mind opening an issue over there instead?