2015-04-17 2 views
0

у меня есть это:Почему рабочие точки jQuery не работают?

<script src="js/jquery.waypoints.min.js"></script> 
<script src="js/jquery.waypoints.js"></script> 

Это:

.icon { 
    text-decoration: none; 
    border-bottom: none; 
    position: relative; /*puede ser acá */ 
    opacity: 0.5; 
} 

Эта вещь:

.icon-animate { 
    opacity: 1; 
} 

И, наконец, это:

var $first = $('.icon'); 

$first.waypoint(function(){ 
    $first.addClass('icon-animate'); 
}); 

Файлы называются правильными и они принадлежат к правильной папке. Почему он не работает?

ответ

0

Надлежащим образом, чтобы написать функции с точки маршрута будет следующим:

$first.waypoint(function(direction) { 
    $first.addClass('icon-animate'); 
}); 

Вы можете задать параметры:

// hit the top of your element when scrolling up 
$first.waypoint(function(direction) { 
    if (direction == 'up') { // hit the top of your element when scrolling up 
     $first.addClass('icon-animate'); 
    } 
}); 

// hit the top of your element when scrolling down 
$first.waypoint(function(direction) { 
    if (direction == 'down') { // hit the top of your element when scrolling down 
     $first.addClass('icon-animate'); 
    } 
}); 

// hit the bottom of your element when scrolling up 
$first.waypoint(function(direction) { 
    if (direction == 'up') { 
     $first.addClass('icon-animate'); 
    } 
}, { offset: function() { return ((-$(this).height() + $("body").height())) } }); 

// hit the bottom of your element when scrolling down 
$first.waypoint(function(direction) { 
    if (direction == 'down') { 
     $first.addClass('icon-animate'); 
    } 
}, { offset: function() { return ((-$(this).height() + $("body").height())) } }); 
+0

У вас есть идея, почему он еще не работает? – user3235483

+0

Я добавил функцию $ (document) .ready и удалил ограничение смещения, и он работает – user3235483

0

Удалите одну из путевых точек JS-файлов. Он не может включать оба.

<script src="js/jquery.waypoints.min.js"></script> 
<script src="js/jquery.waypoints.js"></script> 
+0

Вы просто заставило меня понять, что второй должен быть назван waypoints.js (без части jquery.). Это все еще не работает, но спасибо, что заставил меня заметить одну из моих многочисленных ошибок. – user3235483

Смежные вопросы