| @@ -68,10 +68,10 @@ bulma_document <- function( | |||
| script = "gumshoe.min.js" | |||
| ), | |||
| if (toc) htmltools::htmlDependency( | |||
| name = "vanillajs-scrollspy", | |||
| version = "2.0.3", | |||
| name = "smoothscroll", | |||
| version = "0.4.0", | |||
| src = bulma_file("bulma"), | |||
| script = "vanillajs-scrollspy.min.js" | |||
| script = "smoothscroll.min.js" | |||
| ) | |||
| ) | |||
| @@ -169,12 +169,10 @@ $if(rmarkdown-will-handle-deps)$ | |||
| $else$ | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/gumshoe/3.5.1/js/gumshoe.min.js"></script> | |||
| <script src="https://raw.githubusercontent.com/ederssouza/vanillajs-scrollspy/master/dist/vanillajs-scrollspy.min.js"></script> | |||
| <script src="https://raw.githubusercontent.com/alicelieutier/smoothScroll/master/smoothscroll.min.js"></script> | |||
| $endif$ | |||
| <script> | |||
| gumshoe.init({activeClass: "has-text-weight-semibold"}); | |||
| const toc = document.querySelector('#toc-aside'); | |||
| const scrollspy = new VanillaScrollspy(toc, 1000, 'easeInOutQuint'); | |||
| scrollspy.init(); | |||
| // Add appropriate TOC classes | |||
| document.addEventListener("DOMContentLoaded", function(event) { | |||
| var toc = document.getElementById('toc-aside').getElementsByTagName("ul"); | |||
| @@ -10,3 +10,7 @@ vanillajs-scrollspy: | |||
| version: 2.0.3 | |||
| url: https://raw.githubusercontent.com/ederssouza/vanillajs-scrollspy/master/dist/vanillajs-scrollspy.min.js | |||
| license: MIT 2018 Eder Sampaio | |||
| smoothscroll: | |||
| version: 0.40 | |||
| url: https://raw.githubusercontent.com/alicelieutier/smoothScroll/master/smoothscroll.min.js | |||
| license: MIT 2013 Alice Lieutier | |||
| @@ -0,0 +1 @@ | |||
| (function(root,smoothScroll){"use strict";if(typeof define==="function"&&define.amd){define(smoothScroll)}else if(typeof exports==="object"&&typeof module==="object"){module.exports=smoothScroll()}else{root.smoothScroll=smoothScroll()}})(this,function(){"use strict";if(typeof window!=="object")return;if(document.querySelectorAll===void 0||window.pageYOffset===void 0||history.pushState===void 0){return}var getTop=function(element,start){if(element.nodeName==="HTML")return-start;return element.getBoundingClientRect().top+start};var easeInOutCubic=function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1};var position=function(start,end,elapsed,duration){if(elapsed>duration)return end;return start+(end-start)*easeInOutCubic(elapsed/duration)};var smoothScroll=function(el,duration,callback,context){duration=duration||500;context=context||window;var start=context.scrollTop||window.pageYOffset;if(typeof el==="number"){var end=parseInt(el)}else{var end=getTop(el,start)}var clock=Date.now();var requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(fn){window.setTimeout(fn,15)};var step=function(){var elapsed=Date.now()-clock;if(context!==window){context.scrollTop=position(start,end,elapsed,duration)}else{window.scroll(0,position(start,end,elapsed,duration))}if(elapsed>duration){if(typeof callback==="function"){callback(el)}}else{requestAnimationFrame(step)}};step()};var linkHandler=function(ev){if(!ev.defaultPrevented){ev.preventDefault();if(location.hash!==this.hash)window.history.pushState(null,null,this.hash);var node=document.getElementById(this.hash.substring(1));if(!node)return;smoothScroll(node,500,function(el){location.replace("#"+el.id)})}};document.addEventListener("DOMContentLoaded",function(){var internal=document.querySelectorAll('a[href^="#"]:not([href="#"])'),a;for(var i=internal.length;a=internal[--i];){a.addEventListener("click",linkHandler,false)}});return smoothScroll}); | |||
| @@ -1,2 +0,0 @@ | |||
| !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VanillaScrollspy=t():e.VanillaScrollspy=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();var r=function(e){return window.setTimeout(e,1e3/60),e};window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||r;var i=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"easeOutSine";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.menu=t,this.speed=n,this.easing=o}return o(e,[{key:"scrollToY",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=window.scrollY||document.documentElement.scrollTop,o=0,r=Math.max(.1,Math.min(Math.abs(n-t)/this.speed,.8)),i={easeOutSine:function(e){return Math.sin(e*(Math.PI/2))},easeInOutSine:function(e){return-.5*(Math.cos(Math.PI*e)-1)},easeInOutQuint:function(e){return(e/=.5)<1?.5*Math.pow(e,5):.5*(Math.pow(e-2,5)+2)}};!function u(){var a=(o+=1/60)/r,c=i[e.easing](a);a<1?(window.requestAnimFrame(u),window.scrollTo(0,n+(t-n)*c)):window.scrollTo(0,t)}()}},{key:"menuControl",value:function(){var e=void 0,t=void 0,n=void 0,o=this.menu.querySelectorAll('a[href^="#"]'),r=window.scrollY||document.documentElement.scrollTop;for(e=0;e<o.length;e+=1)t=o[e],(n=document.querySelector(t.getAttribute("href"))).offsetTop<=r&&n.offsetTop+n.clientHeight>r?t.classList.add("active"):t.classList.remove("active")}},{key:"animated",value:function(){var e=this;function t(t){t.preventDefault();var n=document.querySelector(this.hash);e.scrollToY(n.offsetTop)}var n=void 0,o=this.menu.querySelectorAll('a[href^="#"]');for(n=0;n<o.length;n+=1)o[n].addEventListener("click",t)}},{key:"init",value:function(){var e=this;this.animated(),document.addEventListener("scroll",function(){e.menuControl()})}}]),e}();t.default=i},function(e,t,n){"use strict";e.exports=n(0).default}])}); | |||
| //# sourceMappingURL=vanillajs-scrollspy.min.js.map | |||
| @@ -28,6 +28,7 @@ output: | |||
| keep_md: TRUE | |||
| toc: yes | |||
| toc_depth: 2 | |||
| pandoc_args: ["--variable", "no-font-awesome"] | |||
| # css: custom.css | |||
| rmarkdown::html_document: default | |||
| html_document_base: | |||