fix: Prevent initial unnecessary IntersectionObserver callback execution by sy-records · Pull Request #2523 · docsifyjs/docsify

@sy-records

Summary

  • Added a flag (isInitialLoad) to skip the first callback execution of the IntersectionObserver on page load.

Related issue, if any:

Fix #2504
Fix #2509

What kind of change does this PR introduce?

Bugfix

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

No

Yes
No

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

@vercel

paulhibbitts

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sy-records , created Sandbox and tested (see issue comments) - all looks good to me!

jhildenbiddle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, @sy-records. A few minor nitpicks.

Koooooo-7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we promote the isInitialLoad to the Object level as a field?
Then, we could reuse and keep consistence when any logic relies on the same isInitialLoad lifecycle flag in future.

@sy-records

@sy-records

@sy-records

paulhibbitts

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jhildenbiddle