File tree 3 files changed +4
-3
lines changed
3 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ A tiny custom element for all your scrollytelling needs! The successor to [`@new
4
4
5
5
## Key features
6
6
7
- - 🐜 ** Less than 700 bytes** brotli'ed, ** less than 800 bytes** gzip'ed
7
+ - 🐜 ** ~ 700 bytes** brotli'ed, ** ~ 800 bytes** gzip'ed
8
8
- 👀 Uses a highly-performant ** [ Intersection Observer] ( https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API ) ** to monitor scrolling changes
9
9
- 📚 Smartly uses scroll events to ** calculate scroll progress** only when needed
10
10
- 🌻 Each ` <scroll-scene> ` element may ** have its own** ` offset ` and ** opt-in** to ` progress ` events
Original file line number Diff line number Diff line change 76
76
</ style >
77
77
< script src ="https://unpkg.com/scroll-scene-element/dist/scroll-scene-element.js " type ="module "> </ script >
78
78
< script type ="module ">
79
- const offset = 0.5 ;
79
+ const offset = 0.75 ;
80
80
81
81
function getRandomIntInclusive ( min , max ) {
82
82
min = Math . ceil ( min ) ;
88
88
89
89
scenes . forEach ( ( scene ) => {
90
90
scene . style . padding = getRandomIntInclusive ( 200 , 400 ) + 'px 0' ;
91
+ scene . offset = offset ;
91
92
} )
92
93
93
94
document . querySelector ( '.midpoint' ) . style . top = ( 1 - offset ) * 100 + '%' ;
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ function observeProgress(element: ScrollSceneElement): ProgressCommands {
86
86
// ensure progress is never less than 0 or greater than 1
87
87
const progress = Math . max (
88
88
0 ,
89
- Math . min ( ( window . innerHeight * offset - top ) / ( bottom - top ) , 1 ) ,
89
+ Math . min ( ( window . innerHeight * ( 1 - offset ) - top ) / ( bottom - top ) , 1 ) ,
90
90
) ;
91
91
92
92
element . dispatchEvent (
You can’t perform that action at this time.
0 commit comments