Sunday, April 2, 2023
Learning Code
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#
No Result
View All Result
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#
No Result
View All Result
Learning Code
No Result
View All Result
Home JavaScript

Scroll to anchor and highlight menu item not working in Firefox – JavaScript – SitePoint Forums

learningcode_x1mckf by learningcode_x1mckf
January 17, 2023
in JavaScript
0
Time limit for notify – JavaScript – SitePoint Forums
74
SHARES
1.2k
VIEWS
Share on FacebookShare on Twitter


You might also like

4 Packages for Working With Date and Time in JavaScript – MUO – MakeUseOf

Understanding the Power of Proxy in JavaScript – hackernoon.com

JavaScript vs. TypeScript: What's the difference? – TheServerSide.com


mgason



January 13, 2023, 4:20am
#1

My dwelling web page has 7 anchor factors that are the primary 7 objects on my menu. The final menu merchandise “Reservations is a separate web page.

After plenty of blundering work with minimal data I’ve javascript that highlights the proper menu merchandise when the house web page scrolls to the related anchor level. All the pieces appears to work high quality in Chrome and Safari. Works high quality for the cell menu too, at the least on iPhone in Safari. (white inactive, purple lively)

In Firefox it doesn’t work. Scrolling works high quality. Anchors all present lively (purple) when on the homepage. Any ideas on what would make Firefox distinctive?
Take a look at web site is right here https://hotelcasasadev.wpengine.com/
My code is right here https://codepen.io/mgason/pen/MWBmBjm?editors=0010
Video of the issue utilizing 3 browsers is right here https://www.veed.io/view/a2b10045-5b3f-4ebd-a2d0-5e6b4d16174e?panel=share


PaulOB



January 13, 2023, 2:38pm
#2

It appears to be working in my Firefox (albeit a bit sluggish). Have you ever cleared the cache and tried once more?


mgason



January 15, 2023, 4:05am
#3

Fascinating, I’ve cleared cache many occasions, each domestically and at my host. Not simply web page cache however all cache at WPEngine. I’ve additionally shut my laptop down and restarted. I’m additionally testing in a brand new personal window in every browser every time.
Velocity clever I believe my hacked collectively from snippets code will not be superb. Any recommendations on that appreciated.


PaulOB



January 15, 2023, 5:39pm
#4

The menu objects are all in purple now in Chrome (aside from lodging) now so I suppose you might be engaged on the positioning in the intervening time.

mgason:

Velocity clever I believe my hacked collectively from snippets code will not be superb. Any recommendations on that appreciated.

Whenever you verify issues just like the scroll occasion and resize occasion then that causes a delay as they’re checked constantly. You must debounce the routines in order that they solely do their checks much less usually.

I’m not fairly positive whether or not you have been imagined to be altering the menu colour when somebody has scrolled down the web page manually or whether or not you have been simply altering the menu colour when clicked. It will be straightforward to alter the menu colour when clicked as you can simply add a category with js and use that to spotlight the menu merchandise.

Detecting the place on guide scroll is a bit more complicated although.

You don’t want js to scroll to a component today as CSS can do that with scroll-behavior…

1 Like


mgason



January 16, 2023, 2:27am
#5

Sorry about that. I used to be making an attempt one thing. Eradicating the pointless (doc).prepared appeared to make it work in Firefox for me. It additionally appears a bit sooner.
I do change the menu merchandise colour when the consumer scrolls in addition to after they click on a menu merchandise. Any solutions for bettering this code appreciated. What do you imply by debounce the routines?
One other small bug I’ve seen. All anchor menu objects scroll to the best spot, but when I am going to the Reservations web page after which again to a anchor menu merchandise on the house web page, for instance About Us it goes to the best part however it’s aligned with the highest off display screen. Click on one other hyperlink and it will likely be high quality. It’s simply that preliminary Anchor after one other web page.

mgason:

What do you imply by debounce the routines?

You may discover this useful.

CSS-Tricks – 6 Apr 16

Debouncing and Throttling Explained Through Examples | CSS-Tricks

The next is a visitor put up by David Corbacho, a entrance finish engineer in London. We have broached this matter earlier than, however this time, David goes to drive the

As an alternative of utilizing scroll, you can think about using intersection observer as a substitute.


1 Like


PaulOB



January 16, 2023, 1:32pm
#8

mgason:

All anchor menu objects scroll to the best spot, but when I am going to the Reservations web page after which again to a anchor menu merchandise on the house web page, for instance About Us it goes to the best part however it’s aligned with the highest off display screen. Click on one other hyperlink and it will likely be high quality. It’s simply that preliminary Anchor after one other web page.

I believe that’s the identical subject as when you go on to this web page.

https://hotelcasasadev.wpengine.com/#HomeContactUs

The js doesn’t detect the scroll place as you haven’t navigated from the menu.

You most likely want some js to question the url string on web page load and detect if there’s a fragment identifier within the url after which navigate to the proper part as earlier than. @rpg_digital would most likely have higher recommendation :slight_smile:

Be aware that you just don’t get that subject in my demo above (use debug mode to check) and you may hyperlink appropriately to the ingredient because the offset is dealt with in css alone. (In fact you’d nonetheless want js to spotlight the nav merchandise.)



Source link

Share30Tweet19
learningcode_x1mckf

learningcode_x1mckf

Recommended For You

4 Packages for Working With Date and Time in JavaScript – MUO – MakeUseOf

by learningcode_x1mckf
April 1, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

4 Packages for Working With Date and Time in JavaScript  MUO - MakeUseOf Source link

Read more

Understanding the Power of Proxy in JavaScript – hackernoon.com

by learningcode_x1mckf
April 1, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

Understanding the Power of Proxy in JavaScript  hackernoon.com Source link

Read more

JavaScript vs. TypeScript: What's the difference? – TheServerSide.com

by learningcode_x1mckf
April 1, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

JavaScript vs. TypeScript: What's the difference?  TheServerSide.com Source link

Read more

JetBrains updates IDEs for Java, JavaScript, Ruby – InfoWorld

by learningcode_x1mckf
March 31, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

JetBrains updates IDEs for Java, JavaScript, Ruby  InfoWorld Source link

Read more

Virtru Announces First Ever FIPS 140-2 Validated JavaScript … – GlobeNewswire

by learningcode_x1mckf
March 30, 2023
0
Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

Virtru Announces First Ever FIPS 140-2 Validated JavaScript ...  GlobeNewswire Source link

Read more
Next Post
With Java 19, Oracle boosts developer productivity with an eye on the future

With Java 19, Oracle boosts developer productivity with an eye on the future

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related News

Google expands open source bounties, will soon support Javascript fuzzing too – ZDNet

What Are Data Structures and Algorithms in JavaScript? (Definition) – Built In

March 14, 2023
Eight reasons why Java can dominate software development

Eight reasons why Java can dominate software development

November 19, 2022
Senior Java Developer at Datafin Recruitment

Senior Java Developer at Datafin Recruitment

October 11, 2022

Browse by Category

  • C#
  • C++
  • Java
  • JavaScript
  • Python
  • Swift

RECENT POSTS

  • So why did they decide to call it Java? – InfoWorld
  • Senior Java Developer – IT-Online
  • 4 Packages for Working With Date and Time in JavaScript – MUO – MakeUseOf

CATEGORIES

  • C#
  • C++
  • Java
  • JavaScript
  • Python
  • Swift

© 2022 Copyright Learning Code

No Result
View All Result
  • Home
  • JavaScript
  • Java
  • Python
  • Swift
  • C++
  • C#

© 2022 Copyright Learning Code

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?