@contentpilot/sticky-navigation 1.7.3 → 1.7.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Content Pilot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,99 +1,61 @@
1
1
  # Content Pilot Sticky Navigation
2
2
 
3
- Scroll the page and note how the marker animates to highlight all of the sections that are currently on screen.
4
-
5
- ### Installation
6
-
7
- `npm install @contentpilot/sticky-navigation --save-dev`
8
-
9
- ### Require JS file in task runner
10
-
11
- `./node_modules/@contentpilot/sticky-navigation/index.js`
12
-
13
- ### Import and initialize
14
-
15
- `const sticky = require('@contentpilot/sticky-navigation');`
16
-
17
- The options parameter is optional.
18
-
19
- `sticky.init(options);`
20
-
21
- ### Options
22
-
23
- #### clause: String
24
-
25
- Clause element selector. The script will not run if this element does not exist. Default is `.sticky-navigation`. Use syntax of `querySelector`
26
-
27
- ```
28
- const options = {
29
- clause: ''
30
- };
31
- ```
3
+ [![npm version](https://img.shields.io/npm/v/@contentpilot/sticky-navigation.svg)](https://www.npmjs.com/package/@contentpilot/sticky-navigation)
32
4
 
33
- #### identifiers: String
34
-
35
- Selector of elements to which the ID attribute will be added. Default is `h2, h3, h4, h5, h6`. Use syntax of `querySelectorAll`
36
-
37
- ```
38
- const options = {
39
- identifiers: ''
40
- };
41
- ```
5
+ Scroll the page and note how the marker animates to highlight all of the sections that are currently on screen.
42
6
 
43
- #### interceptors: String
7
+ ## Installation
44
8
 
45
- Selector of elements that when intercepted will add the active class in the anchors that have that destination. Default is `h2[id], h3[id], h4[id], h5[id], h6[id]`. Use syntax of `querySelectorAll`
9
+ Install the package:
46
10
 
47
- ```
48
- const options = {
49
- interceptors: ''
50
- };
11
+ ```bash
12
+ npm install @contentpilot/sticky-navigation --save-dev
51
13
  ```
52
14
 
53
- #### offsetAnchor: Number
15
+ Require JS file in task runner:
54
16
 
55
- Offset distance when scrolling. Useful when using a fixed header. Default is `0`. Ignored if offsetElement was defined.
17
+ `./node_modules/@contentpilot/sticky-navigation/index.js`
56
18
 
57
- ```
58
- const options = {
59
- offset: 0
60
- };
61
- ```
19
+ ## Usage
62
20
 
63
- #### offsetElement: String
21
+ **Import and initialize:**
64
22
 
65
- Element selector to calculate offset dynamically. Useful when the offset varies according to an element that is not always present. Default is `empty`.
23
+ ```javascript
24
+ const sticky = require('@contentpilot/sticky-navigation');
66
25
 
67
- ```
68
- const options = {
69
- offsetElement: ''
70
- };
26
+ sticky.init(options);
71
27
  ```
72
28
 
73
- #### inactiveUpperZone: Number
29
+ The options parameter is optional.
74
30
 
75
- Distance in pixels from the top where items are not activated. Useful when you have a fixed header, you scrolls up and you don't want to activate the element while it is behind the header. Default is `0`.
31
+ **With options:**
76
32
 
77
- ```
78
- const options = {
79
- inactiveUpperZone: 170
80
- };
33
+ ```javascript
34
+ sticky.init({
35
+ offsetElement: '.site-header',
36
+ inactiveUpperZone: 170,
37
+ interceptionPercentage: 50,
38
+ });
81
39
  ```
82
40
 
83
- #### interceptionPercentage: Number
41
+ ### Options
84
42
 
85
- Distance in percentage from the top for the items to activate. If for example you want the items to activate when they are in the middle of the screen, use 50. Default is `20`.
43
+ - `clause` - Clause element selector. The script will not run if this element does not exist. Use syntax of `querySelector` (default `.sticky-navigation`)
44
+ - `identifiers` - Selector of elements to which the ID attribute will be added. Use syntax of `querySelectorAll` (default `h2, h3, h4, h5, h6`)
45
+ - `interceptors` - Selector of elements that when intercepted will add the active class in the anchors that have that destination. Use syntax of `querySelectorAll` (default `h2[id], h3[id], h4[id], h5[id], h6[id]`)
46
+ - `offsetAnchor` - Offset distance in pixels when scrolling. Useful when using a fixed header. Ignored if `offsetElement` was defined (default `0`)
47
+ - `offsetElement` - Element selector to calculate offset dynamically. Useful when the offset varies according to an element that is not always present (default empty)
48
+ - `inactiveUpperZone` - Distance in pixels from the top where items are not activated. Useful when you have a fixed header, you scroll up and you don't want to activate the element while it is behind the header (default `0`)
49
+ - `interceptionPercentage` - Distance in percentage from the top for the items to activate. If for example you want the items to activate when they are in the middle of the screen, use `50` (default `20`)
86
50
 
87
- ```
88
- const options = {
89
- interceptionPercentage: 50
90
- };
91
- ```
92
-
93
- ### Publish to NPM
51
+ ## Publish to NPM
94
52
 
95
53
  To update this repository on NPM using the GitHub action,
96
54
 
97
55
  1. Bump the version number in `package.json`
98
- 2. Follow the pattern on your commit message `Release x.x.x`
99
- 3. Push to `main` branch to `origin`
56
+ 2. Open a PR titled `Release x.x.x`
57
+ 3. Squash and merge it once approved
58
+
59
+ ## License
60
+
61
+ MIT
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Add identifiers and activate the anchors that have these identifier
3
- * and are intercepted with the scroll. It needs the proper markup.
4
- * @version 1.7.3
5
- * @package
6
- * @author Content Pilot, Dallas, Texas
7
- * @copyright Copyright © 2018 Content Pilot
2
+ * Sticky Navigation
3
+ * Add identifiers and activate the anchors that have these identifier and are intercepted with the scroll.
4
+ *
5
+ * @author Content Pilot
6
+ * @copyright Copyright (c) 2020 Content Pilot
7
+ * @license MIT
8
8
  */
9
9
 
10
10
  /**
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@contentpilot/sticky-navigation",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
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",
@@ -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
- 24
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
- }
package/eslint.config.js DELETED
@@ -1,23 +0,0 @@
1
- const globals = require('globals');
2
- const jsdoc = require('eslint-plugin-jsdoc');
3
-
4
- module.exports = [
5
- {
6
- ignores: ['node_modules/**'],
7
- },
8
- jsdoc.configs['flat/recommended'],
9
- {
10
- files: ['**/*.js'],
11
- languageOptions: {
12
- sourceType: 'commonjs',
13
- globals: {
14
- ...globals.browser,
15
- },
16
- },
17
- rules: {
18
- quotes: ['error', 'single'],
19
- semi: ['error', 'always'],
20
- camelcase: ['off', { ignoreGlobals: true }],
21
- },
22
- },
23
- ];