javascript - Add class onscroll combined with onepage-scroll.js plug-in -
i'm using onepage-scroll.js (https://github.com/peachananr/onepage-scroll) plug-in on website scroll through homepage. when scrolling past first "slide" add class (sticky) header change css. i've tried code below, can't seem working , i'm kinda in dark here on how make solution work.
var header = $("header"); $("#sliders").scroll(function() { var scroll = $('#sliders').scrolltop(); console.log(scroll); if (scroll >= 50) { header.addclass("sticky"); } else { header.removeclass("sticky"); } });
try make on document ready. down example worked code on onepage-scroll.js
$(document).ready(function(){ $(".main").onepage_scroll({ sectioncontainer: ".sectionscroll", responsivefallback: 600, loop: true, aftermove:function (index){ if ((index == 2)||(index == 3)){ $('#main').addclass('darktheme'); }else{ $('#main').removeclass('darktheme'); } } }); //$(".main").moveto(2); $(".btn-list-bottom").click(function(){$(".main").moveto(4)}); });
all section must have same class.
Comments
Post a Comment