本文介绍了流星滚动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在流星文档中找不到流星的滚动事件.当有人在流星应用程序中向下滚动窗口时,我该怎么做?

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?

我试过了'scroll window' : function(event) { ... },它无法按预期工作.

I've tried 'scroll window' : function(event) { ... } which doesn't work as expected.

推荐答案

我也一直在搞弄.

我还没有找到在Template.template.events中干净地进行此操作的方法.

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

目前明显的临时解决方案是使用一个简单的jQuery滚动事件.

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

$(window).scroll(function(){//your code});应该可以解决问题.

我试图用作选择器但无济于事的事情是:

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

'scroll *'

'scroll body'

'scroll document'

自然

'scroll window'

我在通用模板的事件中尝试了所有这些选择器,并在UI.body的事件中进行了尝试,因为这是包围页面正文的新的火焰模板.

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.

重申一下:暂时最好使用jQuery.

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

这篇关于流星滚动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 00:42