Skip to content

Commit d756528

Browse files
authored
Merge pull request #496 from rtfd/fix-external-display
Fix theme logic and rebuild prod assets
2 parents 3c1a1bb + c19a5e4 commit d756528

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

sphinx_rtd_theme/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159

160160
{# PAGE CONTENT #}
161161
<div class="wy-nav-content">
162-
{% if (theme_style_external_links == 'True') %}
162+
{% if theme_style_external_links|tobool %}
163163
<div class="rst-content style-external-links">
164164
{% else %}
165165
<div class="rst-content">
@@ -207,7 +207,7 @@
207207
{% endif %}
208208

209209
{# STICKY NAVIGATION #}
210-
{% if theme_sticky_navigation %}
210+
{% if theme_sticky_navigation|tobool %}
211211
<script type="text/javascript">
212212
jQuery(function () {
213213
SphinxRtdTheme.StickyNav.enable();

sphinx_rtd_theme/static/css/theme.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sphinx_rtd_theme/static/css/theme.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sphinx_rtd_theme/static/js/theme.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,21 @@ function ThemeNav () {
3030
// Set scroll monitor
3131
self.win.on('scroll', function () {
3232
if (!self.linkScroll) {
33-
self.winScroll = true;
33+
if (!self.winScroll) {
34+
self.winScroll = true;
35+
requestAnimationFrame(function() { self.onScroll(); });
36+
}
3437
}
3538
});
36-
setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);
3739

3840
// Set resize monitor
3941
self.win.on('resize', function () {
40-
self.winResize = true;
42+
if (!self.winResize) {
43+
self.winResize = true;
44+
requestAnimationFrame(function() { self.onResize(); });
45+
}
4146
});
42-
setInterval(function () { if (self.winResize) self.onResize(); }, 25);
47+
4348
self.onResize();
4449
});
4550
};
@@ -168,4 +173,34 @@ if (typeof(window) != 'undefined') {
168173
window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav };
169174
}
170175

176+
177+
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
178+
// https://gist.github.com/paulirish/1579671
179+
// MIT license
180+
181+
(function() {
182+
var lastTime = 0;
183+
var vendors = ['ms', 'moz', 'webkit', 'o'];
184+
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
185+
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
186+
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
187+
|| window[vendors[x]+'CancelRequestAnimationFrame'];
188+
}
189+
190+
if (!window.requestAnimationFrame)
191+
window.requestAnimationFrame = function(callback, element) {
192+
var currTime = new Date().getTime();
193+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
194+
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
195+
timeToCall);
196+
lastTime = currTime + timeToCall;
197+
return id;
198+
};
199+
200+
if (!window.cancelAnimationFrame)
201+
window.cancelAnimationFrame = function(id) {
202+
clearTimeout(id);
203+
};
204+
}());
205+
171206
},{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]);

0 commit comments

Comments
 (0)