Skip to content

Commit

Permalink
v2.1.2 - Fixed scroll position
Browse files Browse the repository at this point in the history
  • Loading branch information
iDev-Games committed Apr 8, 2023
1 parent 4de9ce9 commit f14c60f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
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 @@ -3,7 +3,7 @@
<title>Trig.js Documentation</title>

<!-- Trig JS -->
<script src="dist/trig.js"></script>
<script src="src/trig.js"></script>

<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trig-js",
"version": "2.1.0",
"version": "2.1.2",
"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.",
"main": "src/trig.js",
"scripts": {
Expand Down
22 changes: 15 additions & 7 deletions src/trig.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Trig.js v2.1.1 by iDev Games */
/* Trig.js v2.1.2 by iDev Games */
class Trig
{
trigs = [];
Expand Down Expand Up @@ -105,21 +105,29 @@ class Trig
cl.add("trig-scroll-up");
}
var split = [0,25,50,75,100];
for (let i = 0; i < 4; i++) {
for (let i = 0; i < split.length; i++) {
trig.trigSplit(split[i], element.index, cl);
}
}
trigSplit(split, index, cl){
var name = split;
if(split == 0){
name = "top";
} else if(split == 100){
} else if(split == 100) {
name = "bottom";
}
if(trig.thePos[index] >= split){
cl.add("trig-scroll-"+name);
} else if(trig.thePos[index] < split) {
cl.remove("trig-scroll-"+name);
if(split == 0 || split == 100){
if(trig.thePos[index] == split){
cl.add("trig-scroll-"+name);
} else {
cl.remove("trig-scroll-"+name);
}
} else {
if(trig.thePos[index] >= split){
cl.add("trig-scroll-"+name);
} else if(trig.thePos[index] < split) {
cl.remove("trig-scroll-"+name);
}
}
}
updatePos(element) {
Expand Down

0 comments on commit f14c60f

Please sign in to comment.