Scroll event for Meteor

后端 未结 5 1699
没有蜡笔的小新
没有蜡笔的小新 2021-02-07 20:29

I couldn\'t find a scroll event for meteor in the meteor docs. How do I go about doing something as someone scrolls the window down in a meteor application?

I\'ve tried

5条回答
  •  爱一瞬间的悲伤
    2021-02-07 21:00

    I've been messing around with this as well.

    I haven't found a way to do it cleanly within Template.template.events.

    The obvious temporary solution right now would be using a simple jQuery scroll event.

    $(window).scroll(function(){//your code}); should do the trick.

    Things I was trying to use as the selector but to no avail were:

    'scroll *'

    'scroll body'

    'scroll document'

    and naturally

    'scroll window'

    I tried all of these selectors inside of a generic template's events, along with on UI.body's events, as that's the new blaze template that encompasses the page's body.

    To reiterate: You're probably better off using jQuery for the time being.

提交回复
热议问题