mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
Merge pull request #251 from snide/check-running
Add check for an already running nav
This commit is contained in:
commit
8c880a64fa
41
js/theme.js
41
js/theme.js
@ -12,33 +12,36 @@ function ThemeNav () {
|
|||||||
winPosition: 0,
|
winPosition: 0,
|
||||||
winHeight: null,
|
winHeight: null,
|
||||||
docHeight: null,
|
docHeight: null,
|
||||||
isRunning: null
|
isRunning: false
|
||||||
};
|
};
|
||||||
|
|
||||||
nav.enable = function () {
|
nav.enable = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
jQuery(function ($) {
|
if (!self.isRunning) {
|
||||||
self.init($);
|
self.isRunning = true;
|
||||||
|
jQuery(function ($) {
|
||||||
|
self.init($);
|
||||||
|
|
||||||
self.reset();
|
self.reset();
|
||||||
self.win.on('hashchange', self.reset);
|
self.win.on('hashchange', self.reset);
|
||||||
|
|
||||||
// Set scroll monitor
|
// Set scroll monitor
|
||||||
self.win.on('scroll', function () {
|
self.win.on('scroll', function () {
|
||||||
if (!self.linkScroll) {
|
if (!self.linkScroll) {
|
||||||
self.winScroll = true;
|
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 ($) {
|
nav.init = function ($) {
|
||||||
|
@ -13,33 +13,36 @@ function ThemeNav () {
|
|||||||
winPosition: 0,
|
winPosition: 0,
|
||||||
winHeight: null,
|
winHeight: null,
|
||||||
docHeight: null,
|
docHeight: null,
|
||||||
isRunning: null
|
isRunning: false
|
||||||
};
|
};
|
||||||
|
|
||||||
nav.enable = function () {
|
nav.enable = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
jQuery(function ($) {
|
if (!self.isRunning) {
|
||||||
self.init($);
|
self.isRunning = true;
|
||||||
|
jQuery(function ($) {
|
||||||
|
self.init($);
|
||||||
|
|
||||||
self.reset();
|
self.reset();
|
||||||
self.win.on('hashchange', self.reset);
|
self.win.on('hashchange', self.reset);
|
||||||
|
|
||||||
// Set scroll monitor
|
// Set scroll monitor
|
||||||
self.win.on('scroll', function () {
|
self.win.on('scroll', function () {
|
||||||
if (!self.linkScroll) {
|
if (!self.linkScroll) {
|
||||||
self.winScroll = true;
|
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 ($) {
|
nav.init = function ($) {
|
||||||
|
Loading…
Reference in New Issue
Block a user