mirror of
https://github.com/biobulkbende/biobulkbende.org.git
synced 2024-12-28 22:05:24 +00:00
31 lines
702 B
JavaScript
31 lines
702 B
JavaScript
|
import $ from 'jquery';
|
||
|
import waypoints from '../../../../node_modules/waypoints/lib/noframework.waypoints';
|
||
|
|
||
|
class RevealOnScroll {
|
||
|
constructor(els, offset){
|
||
|
this.itemsToReveal = els;
|
||
|
this.offsetPercentage = offset;
|
||
|
this.hideInitially();
|
||
|
this.createWaypoints();
|
||
|
}
|
||
|
|
||
|
hideInitially() {
|
||
|
this.itemsToReveal.addClass("reveal-item");
|
||
|
}
|
||
|
|
||
|
createWaypoints() {
|
||
|
var that = this;
|
||
|
this.itemsToReveal.each( function(){
|
||
|
var currentItem = this;
|
||
|
new Waypoint({
|
||
|
element: currentItem,
|
||
|
handler: function() {
|
||
|
$(currentItem).addClass("reveal-item--is-visible");
|
||
|
},
|
||
|
offset: that.offsetPercentage
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default RevealOnScroll;
|