Skip to content

Commit

Permalink
v2.1.1 - Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
iDev-Games committed Apr 8, 2023
1 parent 581ae4d commit 4de9ce9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var(--trig-deg-reverse) /* Reverse degrees */
Trig.js creates a class of "trig-scroll-up" or "trig-scroll-down" onto the body of the document depending on the last scroll direction.

# Scroll Position
Trig.js creates a class of "trig-scroll-top" or "trig-scroll-bottom" onto the body of the document depending on the last scroll position. To give the ability to make something happen at different break points down the page. The classes "trig-scroll-25", "trig-scroll-50" and "trig-scroll-75" are added to the body of the document depending on the scoll position percentage down the page.
Trig.js creates a class of "trig-scroll-top" or "trig-scroll-bottom" onto the body of the document depending on the last scroll position. To give the ability to make something happen at different break points down the page. The classes "trig-scroll-25", "trig-scroll-50" and "trig-scroll-75" are added to the body of the document depending on the scroll position percentage down the page.

# Data Attributes
You can use the below data attributes for additional features
Expand Down
2 changes: 1 addition & 1 deletion dist/trig.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ <h2>Scroll Direction</h2>
<h2>Scroll Position</h2>
</div>
<div class="box fadeIn" data-trig>
<p>Trig.js creates a class of "trig-scroll-top" or "trig-scroll-bottom" onto the body of the document depending on the last scroll position. To give the ability to make something happen at different break points down the page. The classes "trig-scroll-25", "trig-scroll-50" and "trig-scroll-75" are added to the body of the document depending on the scoll position percentage down the page.</p>
<p>Trig.js creates a class of "trig-scroll-top" or "trig-scroll-bottom" onto the body of the document depending on the last scroll position. To give the ability to make something happen at different break points down the page. The classes "trig-scroll-25", "trig-scroll-50" and "trig-scroll-75" are added to the body of the document depending on the scroll position percentage down the page.</p>
</div>
</div>

Expand Down
24 changes: 10 additions & 14 deletions src/trig.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Trig.js v2.1.0 by iDev Games */
/* Trig.js v2.1.1 by iDev Games */
class Trig
{
trigs = [];
Expand Down Expand Up @@ -104,26 +104,22 @@ class Trig
if(!cl.contains(trig.scrollDir[0]) && !cl.contains(trig.scrollDir[1])){
cl.add("trig-scroll-up");
}
if(trig.thePos[element.index] == 0){
cl.add("trig-scroll-top");
} else {
cl.remove("trig-scroll-top");
}
if(trig.thePos[element.index] == 100){
cl.add("trig-scroll-bottom");
} else {
cl.remove("trig-scroll-bottom");
}
var split = [25,50,75];
var split = [0,25,50,75,100];
for (let i = 0; i < 4; i++) {
trig.trigSplit(split[i], element.index, cl);
}
}
trigSplit(split, index, cl){
var name = split;
if(split == 0){
name = "top";
} else if(split == 100){
name = "bottom";
}
if(trig.thePos[index] >= split){
cl.add("trig-scroll-"+split);
cl.add("trig-scroll-"+name);
} else if(trig.thePos[index] < split) {
cl.remove("trig-scroll-"+split);
cl.remove("trig-scroll-"+name);
}
}
updatePos(element) {
Expand Down

0 comments on commit 4de9ce9

Please sign in to comment.