Skip to content

Commit

Permalink
Merge pull request #251 from snide/check-running
Browse files Browse the repository at this point in the history
Add check for an already running nav
  • Loading branch information
ericholscher committed Sep 23, 2015
2 parents 84b5075 + d01cb61 commit 8c880a6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 42 deletions.
45 changes: 24 additions & 21 deletions js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,36 @@ function ThemeNav () {
winPosition: 0,
winHeight: null,
docHeight: null,
isRunning: null
isRunning: false
};

nav.enable = function () {
var self = this;

jQuery(function ($) {
self.init($);

self.reset();
self.win.on('hashchange', self.reset);

// Set scroll monitor
self.win.on('scroll', function () {
if (!self.linkScroll) {
self.winScroll = true;
}
if (!self.isRunning) {
self.isRunning = true;
jQuery(function ($) {
self.init($);

self.reset();
self.win.on('hashchange', self.reset);

// Set scroll monitor
self.win.on('scroll', function () {
if (!self.linkScroll) {
self.winScroll = true;
}
});
setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);

// Set resize monitor
self.win.on('resize', function () {
self.winResize = true;
});
setInterval(function () { if (self.winResize) self.onResize(); }, 25);
self.onResize();
});
setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);

// Set resize monitor
self.win.on('resize', function () {
self.winResize = true;
});
setInterval(function () { if (self.winResize) self.onResize(); }, 25);
self.onResize();
});
};
};

nav.init = function ($) {
Expand Down
45 changes: 24 additions & 21 deletions sphinx_rtd_theme/static/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,36 @@ function ThemeNav () {
winPosition: 0,
winHeight: null,
docHeight: null,
isRunning: null
isRunning: false
};

nav.enable = function () {
var self = this;

jQuery(function ($) {
self.init($);

self.reset();
self.win.on('hashchange', self.reset);

// Set scroll monitor
self.win.on('scroll', function () {
if (!self.linkScroll) {
self.winScroll = true;
}
if (!self.isRunning) {
self.isRunning = true;
jQuery(function ($) {
self.init($);

self.reset();
self.win.on('hashchange', self.reset);

// Set scroll monitor
self.win.on('scroll', function () {
if (!self.linkScroll) {
self.winScroll = true;
}
});
setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);

// Set resize monitor
self.win.on('resize', function () {
self.winResize = true;
});
setInterval(function () { if (self.winResize) self.onResize(); }, 25);
self.onResize();
});
setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);

// Set resize monitor
self.win.on('resize', function () {
self.winResize = true;
});
setInterval(function () { if (self.winResize) self.onResize(); }, 25);
self.onResize();
});
};
};

nav.init = function ($) {
Expand Down

0 comments on commit 8c880a6

Please sign in to comment.