You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-30
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# wiscroll
2
2
3
-
Scroll based animation JavaScript library. Vanilla js, 0 dependencies, ES6. Lightweight (around 1.6KB minified & gzipped). IntersectionObserver and scroll event based. Performance driven. Created recently due to frustration with IntersectionObserver and existing libraries. The library does not handle CSS, but examples with CSS will be put in the documentation. More documentation and demo are coming.
3
+
Scroll based animation JavaScript library. Vanilla js, 0 dependencies. Lightweight: around 2.5KB transpiled ES5 (or 1.7KB ES6) minified & gzipped. IntersectionObserver based. Performance driven. The library does not handle CSS, but examples with CSS will be put in the documentation. More documentation and demo are coming.
*`rootBorderPosition`: specify a root border (or line), could be `top`, `bottom`, percentage number (e.g. `90%`), pixel number (e.g. `40px`), must be followed by `%` or `px` even if it's 0 (e.g. `0%`), positive number is position from top, negative number is position from bottom (e.g. `-10%` : 10% from bottom)
28
28
*`targetBorderPosition`: specify a target border, could be `top`, `bottom`
@@ -32,18 +32,18 @@ new Wiscroll(target).on("90% top", "active");
32
32
## .on() : do whatever you want when one of target's borders passes (or doesn't pass) one of root's borders/lines
33
33
If target's top border is higher than root's 90% (from top) line, show "Target border is higher" in console, otherwise show "Target border is lower"
@@ -54,31 +54,31 @@ new Wiscroll(target).on("90% top",
54
54
When target's bottom border is touching (target is going into) root's 50% line, show "Target border is higher" in console
55
55
```javascript
56
56
newWiscroll(target).on(
57
-
"50% bottom in",
57
+
'50% bottom in',
58
58
function(entry) {
59
-
console.log("Target border is passed");
59
+
console.log('Target border is passed');
60
60
}
61
61
);
62
62
```
63
63
By the way, you might want to deal with initial states (when the page has just loaded and script has just been executed). Let's add a function to do something when my target border is higher (and lower) than my root's line
However, it is recommanded you use initFunction in `.on()` instead of `.init()` to have fewer observers.
113
113
114
114
## .fromto() : change target dynamically depending on scroll position
115
115
You can change the target progressively and continuously, or do whatever you want dynamically depending on target's scroll position (a percentage) between the two positions you have specified
116
116
```javascript
117
117
newWiscroll(target).fromto(
118
-
"-10% top",
119
-
"20% bottom",
118
+
'-10% top',
119
+
'20% bottom',
120
120
function(position, entry) { // position is from 0 to 1, could be < 0 or > 1 if out of boundary
[IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) has better performance but there are lots of situation it can't handle, having a scroll event listener that only listens inside the specified area with some throttling added up there might be a good choice.
177
+
[IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) has good performance and can handle every scenario our method `.on()` deals with. Unfortunately, it can't handle some situations related to our `.fromto()` method, having a scroll event listener that only listens inside the specified area with some throttling added up there might be a good choice.
178
178
179
179
</details>
180
180
@@ -187,7 +187,6 @@ If you have basic knowledge of CSS and its [transition](https://developer.mozill
187
187
-[ ] see if this.target.getBoundingClientRect().top should be changed
188
188
-[ ] other tests
189
189
-[ ] test in Edge and mobile browsers
190
-
-[ ] transpile the lib (or not)
191
-
-[ ] I'll see what I can do to support IE11 but frankly I think we should just drop it.
190
+
-[ ] I'll see what I can do to support IE11, will a simple polyfill of IntersectionObserver make it work? I'll try. But frankly I think we should just drop IE11.
0 commit comments