Skip to content

Commit fd51c87

Browse files
committed
v4.2.0 - Sets the data-attribute to increments of 10 for more control
1 parent bf45647 commit fd51c87

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ To activate trig.js add the data attribute "data-trig" or a class "enable-trig"
9595
}
9696
```
9797

98-
The classes of "trig-up" and "trig-down"
99-
10098
# Scroll Animations
10199
Trig.js calculates the percentage that the element is on screen and creates CSS variables that you can use with CSS transform etc.
102100

@@ -120,6 +118,21 @@ var(--trig-deg) /* Degrees */
120118
var(--trig-deg-reverse) /* Reverse degrees */
121119
```
122120

121+
The data attribute will also update in incremants of 10 so you can use CSS attribute selectors like:
122+
123+
```css
124+
[data-trig-var="50"],
125+
[data-trig-var="60"],
126+
[data-trig-var="70"],
127+
[data-trig-var="80"],
128+
[data-trig-var="90"],
129+
[data-trig-var="100"]{
130+
transform: translateX( var(--trig) );
131+
}
132+
```
133+
134+
for more control.
135+
123136
# Scroll Direction
124137
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.
125138

dist/trig.min.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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
top:0;
131131
left:0px;
132132
background-image:url("assets/img/wheel.png");
133-
background-size: auto 100%;
133+
background-size: contain;
134134
background-position: center;
135135
background-repeat: no-repeat;
136136
transform: translateX(calc(var(--trig) - 75%)) rotate(calc(var(--trig-deg)));
@@ -387,7 +387,7 @@ <h1 id="logo" data-trig-min="30" data-trig>Trig.js</h1>
387387

388388
<hr id="headerLine" data-trig-min="20" data-trig />
389389

390-
<h2 id="documentation" data-trig-min="20" data-trig>Documentation <sup>v4.1.1</sup></h2>
390+
<h2 id="documentation" data-trig-min="20" data-trig>Documentation <sup>v4.2.0</sup></h2>
391391
</div>
392392
</div>
393393

@@ -498,6 +498,7 @@ <h2>Scroll Animations</h2>
498498
<div class="listItem">
499499
--trig-deg-reverse
500500
</div>
501+
<p>The data attribute will also update in incremants of 10 so you can use CSS attribute selectors like <span class="listItem">[data-trig-var="50"]{ }</span> for more control.</p>
501502
</div>
502503
</div>
503504

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "trig-js",
3-
"version": "4.1.1",
3+
"version": "4.2.0",
44
"description": "Trig.js powers dynamic, CSS-driven animate-on-scroll effects using CSS variables and element position data, making AOS effortless. Create custom animations in CSS or use trig-animations.css for ready-made effects—full control or quick setup. Perfect for storytelling websites.",
55
"main": "src/trig.js",
66
"repository": {

src/trig.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Trig.js v4.1.1 by iDev Games */
1+
/* Trig.js v4.2.0 by iDev Games */
22
class Trig
33
{
44
trigs = [];
@@ -214,7 +214,8 @@ class Trig
214214
setCSSVariables(el, id, properties, element) {
215215
Object.entries(properties).forEach(([attr, { key, value, reverse }]) => {
216216
if(el.getPropertyValue(key) != value){
217-
if (element.dataset[attr] === "true") {
217+
if (element.dataset[attr]) {
218+
element.dataset[attr] = Math.round(parseInt(value) / 10) * 10;
218219
el.setProperty(key + id, value);
219220
el.setProperty(key + id + "-reverse", reverse);
220221
}
@@ -241,4 +242,4 @@ const trig = new Trig;
241242

242243
window.addEventListener("scroll", trig.trigScroll, { passive: true });
243244
window.addEventListener('resize', trig.trigWindowHeight, { passive: true });
244-
window.addEventListener('load', trig.trigInit, { passive: true });
245+
window.addEventListener('load', trig.trigInit, { passive: true });

0 commit comments

Comments
 (0)