@contentpilot/sticky-navigation 1.7.2 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Content Pilot Sticky Navigation
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@contentpilot/sticky-navigation.svg)](https://www.npmjs.com/package/@contentpilot/sticky-navigation)
4
+
3
5
  Scroll the page and note how the marker animates to highlight all of the sections that are currently on screen.
4
6
 
5
7
  ### Installation
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Add identifiers and activate the anchors that have these identifier
3
3
  * and are intercepted with the scroll. It needs the proper markup.
4
- * @version 1.7.2
4
+ * @version 1.7.4
5
5
  * @package
6
6
  * @author Content Pilot, Dallas, Texas
7
7
  * @copyright Copyright © 2018 Content Pilot
@@ -178,7 +178,7 @@ function _getElements(input) {
178
178
  }
179
179
 
180
180
  /**
181
- * Get the element full height including margins.
181
+ * Get the element full height including margins.
182
182
  * @param {string} selector - A CSS selector string.
183
183
  * @returns {number} - The element height including margins.
184
184
  */
@@ -192,7 +192,7 @@ function _getElementFullHeight(selector) {
192
192
  const height = element.offsetHeight;
193
193
  const styles = window.getComputedStyle(element);
194
194
  const margin = parseInt(styles.getPropertyValue('margin-top')) + parseInt(styles.getPropertyValue('margin-bottom'));
195
-
195
+
196
196
  return (height + margin);
197
197
  }
198
198
 
@@ -207,7 +207,8 @@ function _addScrollBehavior(offsetFixed, offsetElement) {
207
207
  e.preventDefault();
208
208
 
209
209
  const id = this.getAttribute('href').replace('#', '');
210
- const rect = document.getElementById(id).getBoundingClientRect();
210
+ const target = document.getElementById(id);
211
+ const rect = target.getBoundingClientRect();
211
212
 
212
213
  // Position of element relative to screen + Window scrolling position.
213
214
  const top = rect.top + window.scrollY;
@@ -222,6 +223,13 @@ function _addScrollBehavior(offsetFixed, offsetElement) {
222
223
  left: 0,
223
224
  behavior: 'smooth',
224
225
  });
226
+
227
+ if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) {
228
+ target.setAttribute('tabindex', '-1');
229
+ target.style.outline = 'none';
230
+ }
231
+
232
+ target.focus({ preventScroll: true });
225
233
  });
226
234
  });
227
235
  }
@@ -304,9 +312,13 @@ function _addActiveClass(node) {
304
312
 
305
313
  activeElements.forEach(function (element) {
306
314
  element.classList.remove('current-menu-item');
315
+ element.querySelectorAll('a[aria-current]').forEach(function (anchor) {
316
+ anchor.removeAttribute('aria-current');
317
+ });
307
318
  });
308
319
 
309
320
  node.parentElement.classList.add('current-menu-item');
321
+ node.setAttribute('aria-current', 'location');
310
322
  }
311
323
  }
312
324
 
@@ -317,5 +329,6 @@ function _addActiveClass(node) {
317
329
  function _removeActiveClass(node) {
318
330
  if (node) {
319
331
  node.parentElement.classList.remove('current-menu-item');
332
+ node.removeAttribute('aria-current');
320
333
  }
321
334
  }
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@contentpilot/sticky-navigation",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "Add identifiers and activate the anchors that have these identifier and are intercepted with the scroll.",
5
5
  "main": "index.js",
6
+ "files": [
7
+ "index.js"
8
+ ],
6
9
  "publishConfig": {
7
10
  "access": "public"
8
11
  },
9
12
  "repository": {
10
13
  "type": "git",
11
- "url": "https://github.com/contentpilot/sticky-navigation"
14
+ "url": "git+https://github.com/content-pilot/sticky-navigation.git"
12
15
  },
13
16
  "keywords": [
14
17
  "WordPress",
@@ -19,8 +22,9 @@
19
22
  "author": "Content Pilot",
20
23
  "license": "MIT",
21
24
  "devDependencies": {
22
- "eslint": "^8.57.0",
23
- "eslint-plugin-jsdoc": "^48.5.2"
25
+ "eslint": "^10.11.0",
26
+ "eslint-plugin-jsdoc": "^65.0.1",
27
+ "globals": "^17.13.0"
24
28
  },
25
29
  "scripts": {
26
30
  "lint": "eslint *.js --fix"
package/.eslintignore DELETED
@@ -1 +0,0 @@
1
- /node_modules/**
package/.eslintrc.js DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- es6: true,
5
- },
6
- extends: ['plugin:jsdoc/recommended'],
7
- rules: {
8
- quotes: [ 'error', 'single' ],
9
- semi: [ 'error', 'always' ],
10
- camelcase: [ 'off', { ignoreGlobals: true } ],
11
- }
12
- };
@@ -1,33 +0,0 @@
1
- name: Publish NPM Package
2
- on:
3
- push:
4
- branches:
5
- - main
6
- jobs:
7
- npm-publish:
8
- name: Publish
9
- runs-on: ubuntu-latest
10
- steps:
11
- - name: Checkout repository
12
- uses: actions/checkout@main
13
- - name: Set up Node.js
14
- uses: actions/setup-node@v4
15
- with:
16
- node-version: '20.x'
17
- registry-url: 'https://registry.npmjs.org'
18
- - name: Check Commit Message
19
- id: check_commit
20
- run: |
21
- COMMIT_MSG=$(git log -1 --pretty=%B)
22
- PATTERN="^Release (\\S+)"
23
- if [[ "$COMMIT_MSG" =~ $PATTERN ]]; then
24
- echo "MATCHED=true" >> $GITHUB_ENV
25
- echo "TAG_NAME=${BASH_REMATCH[1]}" >> $GITHUB_ENV
26
- else
27
- echo "MATCHED=false" >> $GITHUB_ENV
28
- fi
29
- - name: Publish to NPM
30
- if: env.MATCHED == 'true'
31
- run: npm publish
32
- env:
33
- NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- 20
package/.prettierrc.js DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- useTabs: true,
3
- tabWidth: 4,
4
- printWidth: 80,
5
- singleQuote: true,
6
- trailingComma: 'es5',
7
- bracketSpacing: true,
8
- parenSpacing: true,
9
- jsxBracketSameLine: false,
10
- semi: true,
11
- arrowParens: 'always',
12
- }