From 9c1943c46750e3414df319f45b536c2a84f2fa10 Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Mon, 13 Jan 2014 11:51:21 -0800 Subject: [PATCH] Adjust docs to waypoints 2.x and add a delay for deps flush to increase performance on scroll. --- docs/client/docs.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/client/docs.js b/docs/client/docs.js index 4ecb004ab5..c878bc9013 100644 --- a/docs/client/docs.js +++ b/docs/client/docs.js @@ -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); + } } });