Skip to content

Commit cea4d63

Browse files
committed
v2.2 - Added negativeOffset
1 parent 30d0e87 commit cea4d63

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Trig.js creates a class of "trig-scroll-top" or "trig-scroll-bottom" onto the bo
117117
You can use the below data attributes for additional features
118118

119119
```html
120-
<div id="yourelement" data-trig-min="-100" data-trig-max="100" data-trig-offset="0" data-trig-height="0" data-trig-global="false" data-trig> </div>
120+
<div id="yourelement" data-trig-min="-100" data-trig-max="100" data-trig-offset="0" data-trig-negativeOffset="0" data-trig-height="0" data-trig-global="false" data-trig> </div>
121121
```
122122

123123
Check out the code of the documentation as an example.

dist/trig.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ <h2>Data Attributes</h2>
295295
<p>You can use the below data attributes for additional features</p>
296296
<div class="listItem">
297297
<pre>
298-
&lt;div id="yourelement" data-trig-min="-100" data-trig-max="100" data-trig-offset="0" data-trig-height="0" data-trig-global="false" data-trig&gt; &lt;/div&gt;
298+
&lt;div id="yourelement" data-trig-min="-100" data-trig-max="100" data-trig-offset="0" data-trig-negativeOffset="0" data-trig-height="0" data-trig-global="false" data-trig&gt; &lt;/div&gt;
299299
</pre>
300300
</div>
301301
</div>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "trig-js",
3-
"version": "2.1.8",
3+
"version": "2.2",
44
"description": "The easy way to create CSS scroll animations that react to the position of your HTML element on screen. Animate on scroll (AOS) your CSS.",
55
"main": "src/trig.js",
66
"repository": {
@@ -32,6 +32,6 @@
3232
},
3333
"homepage": "https://github.com/iDev-Games/trig#readme",
3434
"publishConfig": {
35-
"registry":"https://npm.pkg.github.com/"
35+
"registry": "https://npm.pkg.github.com/"
3636
}
3737
}

src/trig.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Trig.js v2.1.7 by iDev Games */
1+
/* Trig.js v2.2 by iDev Games */
22
class Trig
33
{
44
trigs = [];
@@ -59,7 +59,7 @@ class Trig
5959
}
6060
}
6161
trigPos(entry) {
62-
var options = { offset: 0, height: 0, min: -100, max: 100 };
62+
var options = { negativeOffset: 0, offset: 0, height: 0, min: -100, max: 100 };
6363
Object.keys(options).forEach(function(key) {
6464
options[key] = self.trigAttributes(entry, options, key);
6565
});
@@ -72,7 +72,11 @@ class Trig
7272
var posTop = 0 - (el);
7373
var pos = (posTop / (height - ((self.height)))) * 100;
7474
} else {
75-
var posTop = 0 - (el - ((self.height / 2) + options.offset));
75+
if(options.negativeOffset > 0){
76+
var posTop = 0 - (el - ((self.height / 2) + options.negativeOffset));
77+
} else {
78+
var posTop = 0 - (el - ((self.height / 2) - options.offset));
79+
}
7680
var pos = (posTop / (height + options.height)) * 100;
7781
}
7882
self.trigSetPos(pos, options.min, options.max, entry.target);

0 commit comments

Comments
 (0)