diff --git a/nbconvert/exporters/slides.py b/nbconvert/exporters/slides.py index 42bc8cd77..32a4ce9b8 100644 --- a/nbconvert/exporters/slides.py +++ b/nbconvert/exporters/slides.py @@ -6,7 +6,7 @@ from copy import deepcopy from warnings import warn -from traitlets import Unicode, default +from traitlets import Bool, Unicode, default from .html import HTMLExporter @@ -103,6 +103,21 @@ def _reveal_url_prefix_default(self): """ ).tag(config=True) + reveal_transition = Unicode('slide', + help=""" + Name of the reveal.js transition to use. + + The list of transitions that ships by default with reveal.js are: + none, fade, slide, convex, concave and zoom. + """ + ).tag(config=True) + + reveal_scroll = Bool(False, + help=""" + If True, enable scrolling within each slide + """ + ).tag(config=True) + require_js_url = Unicode( "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js", help=""" @@ -146,6 +161,8 @@ def from_notebook_node(self, nb, resources=None, **kw): resources['reveal'] = {} resources['reveal']['url_prefix'] = self.reveal_url_prefix resources['reveal']['theme'] = self.reveal_theme + resources['reveal']['transition'] = self.reveal_transition + resources['reveal']['scroll'] = self.reveal_scroll resources['reveal']['require_js_url'] = self.require_js_url resources['reveal']['jquery_url'] = self.jquery_url resources['reveal']['font_awesome_url'] = self.font_awesome_url diff --git a/nbconvert/postprocessors/serve.py b/nbconvert/postprocessors/serve.py index 872c8db7f..6c73240c4 100644 --- a/nbconvert/postprocessors/serve.py +++ b/nbconvert/postprocessors/serve.py @@ -45,7 +45,7 @@ class ServePostProcessor(PostProcessorBase): open_in_browser = Bool(True, help="""Should the browser be opened automatically?""" ).tag(config=True) - reveal_cdn = Unicode("https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.1.0", + reveal_cdn = Unicode("https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.5.0", help="""URL for reveal.js CDN.""" ).tag(config=True) reveal_prefix = Unicode("reveal.js", help="URL prefix for reveal.js").tag(config=True) diff --git a/nbconvert/templates/html/slides_reveal.tpl b/nbconvert/templates/html/slides_reveal.tpl index 16890c174..bd1e06b15 100644 --- a/nbconvert/templates/html/slides_reveal.tpl +++ b/nbconvert/templates/html/slides_reveal.tpl @@ -85,7 +85,6 @@ if( window.location.search.match( /print-pdf/gi ) ) { /* Overrides of notebook CSS for static HTML export */ .reveal { font-size: 160%; - overflow-y: scroll; } .reveal pre { width: inherit; @@ -116,6 +115,41 @@ if( window.location.search.match( /print-pdf/gi ) ) { .reveal .progress { position: static; } +.reveal .controls .navigate-left, +.reveal .controls .navigate-left.enabled { + border-right-color: #727272; +} +.reveal .controls .navigate-left.enabled:hover, +.reveal .controls .navigate-left.enabled.enabled:hover { + border-right-color: #dfdfdf; +} +.reveal .controls .navigate-right, +.reveal .controls .navigate-right.enabled { + border-left-color: #727272; +} +.reveal .controls .navigate-right.enabled:hover, +.reveal .controls .navigate-right.enabled.enabled:hover { + border-left-color: #dfdfdf; +} +.reveal .controls .navigate-up, +.reveal .controls .navigate-up.enabled { + border-bottom-color: #727272; +} +.reveal .controls .navigate-up.enabled:hover, +.reveal .controls .navigate-up.enabled.enabled:hover { + border-bottom-color: #dfdfdf; +} +.reveal .controls .navigate-down, +.reveal .controls .navigate-down.enabled { + border-top-color: #727272; +} +.reveal .controls .navigate-down.enabled:hover, +.reveal .controls .navigate-down.enabled.enabled:hover { + border-top-color: #dfdfdf; +} +.reveal .progress span { + background: #727272; +} div.input_area { padding: 0.06em; } @@ -149,6 +183,19 @@ a.anchor-link { .rendered_html p { text-align: inherit; } +::-webkit-scrollbar +{ + width: 6px; + height: 6px; +} +::-webkit-scrollbar * +{ + background:transparent; +} +::-webkit-scrollbar-thumb +{ + background: #727272 !important; +} @@ -190,8 +237,7 @@ require( progress: true, history: true, - theme: Reveal.getQueryHash().theme, // available themes are in /css/theme - transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/none + transition: "{{resources.reveal.transition}}", // Optional libraries used to extend on reveal.js dependencies: [ @@ -211,13 +257,25 @@ require( Reveal.addEventListener('slidechanged', update); - var update_scroll = function(event){ - $(".reveal").scrollTop(0); - }; - - Reveal.addEventListener('slidechanged', update_scroll); + function setScrollingSlide() { + var scroll = {{ resources.reveal.scroll | json_dumps }} + if (scroll === true) { + var h = $('.reveal').height() * 0.95; + $('section.present').find('section') + .filter(function() { + return $(this).height() > h; + }) + .css('height', 'calc(95vh)') + .css('overflow-y', 'scroll') + .css('margin-top', '20px'); + } + } + + // check and set the scrolling slide every time the slide change + Reveal.addEventListener('slidechanged', setScrollingSlide); } + );