Add class when scroll down with AlloyUI

只愿长相守 提交于 2020-01-17 11:35:21

问题


I need to add a class when the user scroll down. I usually do this with jQuery:

$(window).scroll(function() {
  var scroll = $(window).scrollTop();
  if (scroll >= 10) {
    $(".dockbar").addClass("dockbar-opacity");
  }
});

How can I do the same thing with AlloyUI? Really thanks.


回答1:


Using the ScrollInfo plugin and its scroll event

var body = Y.one('body');

body.plug(Y.Plugin.ScrollInfo);

body.scrollInfo.on('scroll', function (e) {
    if (e.scrollTop >= 10){
       Y.one('.dockbar').addClass('dockbar-opacity');
    }
});


来源:https://stackoverflow.com/questions/28217479/add-class-when-scroll-down-with-alloyui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!