170
170
</div >
171
171
172
172
<script >
173
- function setStyle (id , top , fontSize , bold , opacity ){
174
- return $ (" #event" + id+ " style" ).html (" #event" + id+ " ::before{top:" + top+ " px;font-size:" + fontSize+ " em;color: rgba(255, 255, 255, " + bold+ " );opacity:" + opacity+ " }\n " + " #event" + id+ " ::after{top:" + ((5 * (fontSize- 1 + 1.5 ))+ top)+ " px;opacity:" + opacity + " }\n " );
173
+ function setStyle (id , top , fontSize , bold , opacity , opacity2 ){
174
+ return $ (" #event" + id+ " style" ).html (" #event" + id+ " ::before{top:" + top+ " px;font-size:" + fontSize+ " em;color: rgba(255, 255, 255, " + bold+ " );opacity:" + opacity+ " }\n " + " #event" + id+ " ::after{top:" + ((5 * (fontSize- 1 + 1.5 ))+ top)+ " px;opacity:" + opacity2 + " }\n " );
175
175
}
176
176
177
177
window .scrollTo (0 , 0 ); // Reset Scroll
201
201
let clientRect = this .getBoundingClientRect ()
202
202
203
203
let x1 = clientRect .top ; // Distance from top of view port to top of element
204
- let x2 = (window .getComputedStyle (this , ' :after' ).top .slice (0 , - 2 )) / $ (this ).height (); // Percentage scroll of ::before and ::after
205
- let x3 = clientRect .bottom ; // Distance from top of view port to bottom of element
206
204
207
205
if (x1 <= 250 && x1 >= 50 ){
208
206
y1 = 1 + ((1 - ((x1- 50 )/ 200 ))* 1 ); // font-size
@@ -225,19 +223,20 @@ h1 {
225
223
}
226
224
}
227
225
228
- if (x2 > 1 ){
229
- y4 = (( 1 - ((x2 - 1 ) / 0.5 )) * 1 ); // Opacity
226
+ if (y3 > $ ( this ). height () ){
227
+ y4 = (1 - ((y3 - $ ( this ). height ()) / 115 ) ); // Opacity
230
228
}
231
229
else {
232
230
y4 = 1 ; // Opacity
233
231
}
234
232
235
- // Prevent Last element from escaping timeline
236
- if ($ (" li.event" ).length == (i+ 1 ) && y3 > $ (this ).height ()){
233
+ // Prevent Last element from escaping timeline OR prevent events from deviating too far off
234
+ if (( $ (" li.event" ).length == (i+ 1 ) && y3 > $ (this ).height ()) || (y3 > $ ( this ). height () + 115 )){
237
235
y3 = $ (this ).height ();
238
236
}
239
237
240
- setStyle (i,y3,y1,y2,y4);
238
+
239
+ setStyle (i,y3,y1,y2,y4,y4+ 1 );
241
240
});
242
241
});
243
242
</script >
0 commit comments