You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pat/navigation/documentation.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,21 @@ Marks navigation paths with "in-path" and "current" classes.
5
5
6
6
## Documentation
7
7
8
-
The "in-path" and "current" classes and the "item-wrapper" are configurable.
8
+
When clicking on a navigation item this one will always get the `current-class`.
9
+
When loading a page and the browser's url matches a navigation item's href value, this one will get the `current-class`.
10
+
Any navigation items in it's path will get the `in-path-class`.
11
+
12
+
### scroll-marker functionality
13
+
14
+
When a content items with an id which matches a hash-url in the navigation are scrolled into view then the corresponding navigation items will get the `in-view-class`.
15
+
One matching navigation item will get the `current-class` and the corresponding content item will get the `current-content-class`, depending on the algorithm in use as described in the [pat-scroll-marker documentation](../scroll-marker/documentation.md).
16
+
The default is that the content item in view, which top position is neares to the middle of the scrolling container will be the current item.
17
+
18
+
### Automatic loading of items
9
19
10
20
You can automatically load the navigation item marked with the `current` class by adding the class `navigation-load-current` along with `pat-navigation` on the pattern element.
11
21
This would invoke a `click` event on the current navigation item and that can be used to load content via `pat-inject`.
|`item-wrapper`|`li`| CSS selector | The DOM element which wraps each menu item. This is used to set the "current" and "in-path" classes also on the wrapper element. If empty, no wrapper element is used. |
23
-
|`in-path-class`|`navigation-in-path`| CSS class name | Class name, which is set on item-wrapper elements if nested menu items are within the current path. |
24
-
|`current-class`|`current`| CSS class name | Class name, which is set on item-wrapper or items if they are the currently selected menu option. |
31
+
| item-wrapper | li | CSS selector | The DOM element which wraps each menu item. This is used to set the "current" and "in-path" classes also on the wrapper element. If empty, no wrapper element is used. |
32
+
| in-path-class | navigation-in-path | CSS class name | Class name, which is set on item-wrapper elements if nested menu items are within the current path. |
33
+
| current-class | current | CSS class name | Class name, which is set on item-wrapper or items if they are the currently selected menu option or - for hash links - when it's corresponding content item is in view. |
34
+
| in-view-class | in-view || String | CSS class for a navigation item when it's corresponding content item is in view. |
35
+
| current-content-class | current || String | CSS class for a content item when it is the current one. |
36
+
| scroll-marker-side | top | top, bottom, middle, auto | String | Side of element that scrolls. This is used to calculate the current item. The defined side of the element will be used to calculate the distance baseline. If this is set to "auto" then one of the "top" or "bottom" positions are used, depending on which one is nearer to the distance baseline. |
37
+
| scroll-marker-distance | 50% || String | Distance from side of scroll box. any amount in px or %. This is used to calculate the current item. The nearest element to the distance-baseline measured from the top of the container will get the current class. |
38
+
| scroll-marker-visibility || null, most-visible | String | Visibility of element in scroll box. This is used to calculate the current item. If "most-visible" is set, the element which is most visible in the scroll container gets the current class. If more elements have the same visibility ratio, the other conditions are used to calculate the current one. |
0 commit comments