@contentpilot/sticky-navigation 1.7.4 → 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -74
  3. package/index.js +6 -6
  4. package/package.json +1 -1
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
@@ -4,98 +4,58 @@
4
4
 
5
5
  Scroll the page and note how the marker animates to highlight all of the sections that are currently on screen.
6
6
 
7
- ### Installation
7
+ ## Installation
8
8
 
9
- `npm install @contentpilot/sticky-navigation --save-dev`
9
+ Install the package:
10
10
 
11
- ### Require JS file in task runner
12
-
13
- `./node_modules/@contentpilot/sticky-navigation/index.js`
14
-
15
- ### Import and initialize
16
-
17
- `const sticky = require('@contentpilot/sticky-navigation');`
18
-
19
- The options parameter is optional.
20
-
21
- `sticky.init(options);`
22
-
23
- ### Options
24
-
25
- #### clause: String
26
-
27
- Clause element selector. The script will not run if this element does not exist. Default is `.sticky-navigation`. Use syntax of `querySelector`
28
-
29
- ```
30
- const options = {
31
- clause: ''
32
- };
33
- ```
34
-
35
- #### identifiers: String
36
-
37
- Selector of elements to which the ID attribute will be added. Default is `h2, h3, h4, h5, h6`. Use syntax of `querySelectorAll`
38
-
39
- ```
40
- const options = {
41
- identifiers: ''
42
- };
11
+ ```bash
12
+ npm install @contentpilot/sticky-navigation --save-dev
43
13
  ```
44
14
 
45
- #### interceptors: String
15
+ Require JS file in task runner:
46
16
 
47
- 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`
48
-
49
- ```
50
- const options = {
51
- interceptors: ''
52
- };
53
- ```
54
-
55
- #### offsetAnchor: Number
56
-
57
- 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`
58
18
 
59
- ```
60
- const options = {
61
- offset: 0
62
- };
63
- ```
19
+ ## Usage
64
20
 
65
- #### offsetElement: String
21
+ **Import and initialize:**
66
22
 
67
- 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');
68
25
 
69
- ```
70
- const options = {
71
- offsetElement: ''
72
- };
26
+ sticky.init(options);
73
27
  ```
74
28
 
75
- #### inactiveUpperZone: Number
29
+ The options parameter is optional.
76
30
 
77
- 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:**
78
32
 
79
- ```
80
- const options = {
81
- inactiveUpperZone: 170
82
- };
33
+ ```javascript
34
+ sticky.init({
35
+ offsetElement: '.site-header',
36
+ inactiveUpperZone: 170,
37
+ interceptionPercentage: 50,
38
+ });
83
39
  ```
84
40
 
85
- #### interceptionPercentage: Number
86
-
87
- 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`.
41
+ ### Options
88
42
 
89
- ```
90
- const options = {
91
- interceptionPercentage: 50
92
- };
93
- ```
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`)
94
50
 
95
- ### Publish to NPM
51
+ ## Publish to NPM
96
52
 
97
53
  To update this repository on NPM using the GitHub action,
98
54
 
99
55
  1. Bump the version number in `package.json`
100
- 2. Follow the pattern on your commit message `Release x.x.x`
101
- 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.4
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentpilot/sticky-navigation",
3
- "version": "1.7.4",
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
6
  "files": [