Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yet Another Sticky Nav PR #1662

Merged
merged 12 commits into from
Jul 17, 2019
Merged

Yet Another Sticky Nav PR #1662

merged 12 commits into from
Jul 17, 2019

Conversation

benlk
Copy link
Collaborator

@benlk benlk commented Apr 11, 2019

Changes

This is ClickUp task IDs #106nk0 and #106rw4

To do:

  • review all height- and top-related settings in this script
  • see how much further we can refine and reduce this script
  • any other fixes for the sticky nav in this version milestone

testing

See #1662 (comment)

@joshdarby
Copy link
Collaborator

joshdarby commented Jun 17, 2019

@benlk This works as expected. I'm going to dive deeper and see if/what we can reduce/refine in navigation.js.

@joshdarby
Copy link
Collaborator

@benlk We can probably combine lines 81-82 into
$(window).on('scroll resize', this.stickyNavScrollCallback.bind(this));

https://github.com/INN/largo/blob/c2ff9278d7994a2a2095627c562fe16b366fb600/js/navigation.js#L81-L82

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ A review job has been created and sent to the PullRequest network.


Check the status or cancel PullRequest code review here - or - cancel by adding [!pr] to the title of the pull request.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Just few readability improvements and simplification


Reviewed with ❤️ by PullRequest

js/navigation.js Outdated Show resolved Hide resolved
js/navigation.js Outdated Show resolved Hide resolved
js/navigation.js Outdated Show resolved Hide resolved
js/navigation.js Outdated Show resolved Hide resolved
js/navigation.js Outdated Show resolved Hide resolved
js/navigation.js Outdated Show resolved Hide resolved
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Due to inactivity, PullRequest has cancelled this review job. You can reactivate the code review job from the PullRequest dashboard

@benlk
Copy link
Collaborator Author

benlk commented Jul 13, 2019

The suggested changes in #1660 (comment) for the problem of the sticky nav not obeying the thing

  • the presence or absence of the sticky nav holder should only be toggled by the presence or absence of the show class
  • CSS relating to the presence or absence of the sticky nav holder should be limited to:
    • default state hide
    • &.show: show
    • all other showing/hiding CSS removed
      • main_nav_hide_article
      • sticky_nav_display
  • Appropriate PHP to ensure that the template starts with the show class in the HTML upon initial page load when it's set to display

Testing criteria for same:

  • when the sticky nav is disabled, the sticky nav markup is not output upon the page
  • when the sticky nav is enabled, on all pages where the sticky nav is displayed, the sticky nav starts beneath the site logo header.
  • scroll behavior of the sticky nav:
    • Scrolling down the page makes the sticky nav go away scrolling up is required to get the sticky nav to display initially
    • scrolling up the page makes the sticky nav reappear
    • scrolling down the page after scrolling up makes the sticky nav disappear again.
  • when the sticky nav is set to "Hide the main navigation on article pages and display only the sticky navigation on article pages" in Theme Options > Navigation:
    • the main nav and header do not appear
    • when loading a page at the top of the page, the sticky nav is initially present
    • when loading a page at a point further down the page, the sticky nav is initially present
    • the sticky nav hides and shows as described above
      • Scrolling down the page makes the sticky nav go away
      • scrolling up the page makes the sticky nav reappear
      • scrolling down the page after scrolling up makes the sticky nav disappear again.

@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

... huh. Looks like the "sticky nav disabled" box doesn't do anything, presently. 🐛

@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

When the sticky nav is set to "Hide the main navigation on article pages and display only the sticky navigation on article pages", and the browser is loaded at the top of the page, scrolling down the page, or down-pause-down, does not cause the sticky nav to disappear. This does not occur when the browser is initially loaded from the middle of the page.

@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

The reason for the sticky nav remaining shown is because of how the nav js assumes that #main=nav exists on the page. In the following code, this.mainNavEl = $('#main-nav')

https://github.com/INN/largo/blob/ce2012511a25af60eda69722e55e6acf3eb5cf78/js/navigation.js#L86-L102

If the element is visible, remove 'show', else make sure it shows.

But there's no check that the element exists.


an aside: I cannot wait to replace the sticky nav's positional js and suchlike with a big @supports (display: sticky) CSS rule to pin the main nav to the top of the page, below a fullwidth header.

@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

Gonna have to merge stickyNavScrollTopHide and stickyNavScrollCallback; they're fighting each other for dominance it looks like.

…nd Navigation.prototype.stickyNavScrollTopHide

As discussed in #1662 (comment)
…lling down; add more commentary to explain things raised with @todo in 73ef9a4.
@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

73ef9a4 fixes the problem identified in #1662 (comment), where "Scrolling down the page makes the sticky nav go away" was not happening.

@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

when the sticky nav is disabled, the sticky nav markup is not output upon the page

This is partly because of ce20125 removing the styles that kept it hidden, but other changes in this PR removed other code related to the case where sticky_nav_display is false.

@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

Note for testing: With inspector tools docked to the window as a sidebar, the windowwidth() method here returns not the width of the page, but the width of the page plus sidebar, which means the values are erroneous. Testing is better done with the inspector tools detached or in the footer configuration, and the window resized physically.

@benlk benlk marked this pull request as ready for review July 15, 2019 18:16
@benlk
Copy link
Collaborator Author

benlk commented Jul 15, 2019

(fixing merge conflict)

@benlk benlk modified the milestone: 0.6.4 Jul 15, 2019
Copy link
Collaborator

@joshdarby joshdarby left a comment

Choose a reason for hiding this comment

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

All of the test cases in #1662 (comment) work as expected.

@benlk benlk merged commit 7beb80d into 0.5-dev Jul 17, 2019
@benlk benlk deleted the 1660-1661-sticky-nav-issues branch July 17, 2019 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants