Jquery Scrolltop() event in meteor

Hello
I have a problem with jquery ScrollTop() function it’s not working in meteor.
I am trying to implement next code:

jQuery(window).scroll(function(){
if (jQuery(document).scrollTop() > 350 ) {
alert(“Fuck yeah!”)
}
});
How to do it workable?

$(window).scroll(function() {
    if ( $(".something").length ) {
      var nav = $(".something");

      if ( $(window).scrollTop() >= 200 ) {
        nav.addClass("active");
      } else
        nav.removeClass("active");
    }
});

our class=“something” element is anchor navigation, which switch to position: fixed when scrolling
lenght is there to be kinda active only on sites where is anchor navigation element.

I just need to show some div when I scroll to 350px, is it possible?

yes, what you describe is possible

Could you show me how to do that?
I did it with next code, but that’s not work:

Template.main.onRendered(function () {
$(window).scroll(function() {
if ( $(window).scrollTop() > 350 ) {
$(".block").show();
}
else{
$(".block").hide();
}
});

your code should work. But we did not attach it to some Main template, as we have no such template.
We let it as pure JS to be loaded by Meteor by default.

Look, I have a main template and when I scroll to some div it have to be visible.
When I write code not inside of main template, it’s still not working, in the bottom is print screen of that

I can’t understand, why that’s still not working

I dont see any issue in that code, only thing I can think of is wring selector for that free-table…
In which case it would not execute ofc.

if I give you link on my meteor project, will you help me?

probably not, but some1 maybe could

2 Likes

I just made a meteorpad with your code

http://meteorpad.com/pad/hfewRpWNMiL2Q7upe/quickHack-scrollTop

it worked, so must be something else with your app