Adjust docs to waypoints 2.x and add a delay for deps flush to increase performance on scroll.

This commit is contained in:
Slava Kim
2014-01-13 11:51:21 -08:00
parent bc736e4695
commit 9c1943c467

View File

@@ -47,10 +47,17 @@ Meteor.startup(function () {
}
var ignore_waypoints = false;
$('body').delegate('h1, h2, h3', 'waypoint.reached', function (evt, dir) {
var lastTimeout = null;
$('h1, h2, h3').waypoint(function (evt, dir) {
if (!ignore_waypoints) {
var active = (dir === "up") ? this.prev : this;
Session.set("section", active.id);
if (active.id) {
if (lastTimeout)
Meteor.clearTimeout(lastTimeout);
lastTimeout = Meteor.setTimeout(function () {
Session.set("section", active.id);
}, 200);
}
}
});