summaryrefslogtreecommitdiff
path: root/_includes/scripts/components/sidebar.js
diff options
context:
space:
mode:
Diffstat (limited to '_includes/scripts/components/sidebar.js')
-rw-r--r--_includes/scripts/components/sidebar.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/_includes/scripts/components/sidebar.js b/_includes/scripts/components/sidebar.js
new file mode 100644
index 0000000..92c5591
--- /dev/null
+++ b/_includes/scripts/components/sidebar.js
@@ -0,0 +1,30 @@
+(function() {
+ var SOURCES = window.TEXT_VARIABLES.sources;
+
+ window.Lazyload.js(SOURCES.jquery, function() {
+ var $pageMask = $('.js-page-mask');
+ var $pageRoot = $('.js-page-root');
+ var $sidebarShow = $('.js-sidebar-show');
+ var $sidebarHide = $('.js-sidebar-hide');
+
+ function freeze(e) {
+ if (e.target === $pageMask[0]) {
+ e.preventDefault();
+ }
+ }
+ function stopBodyScrolling(bool) {
+ if (bool === true) {
+ window.addEventListener('touchmove', freeze, { passive: false });
+ } else {
+ window.removeEventListener('touchmove', freeze, { passive: false });
+ }
+ }
+
+ $sidebarShow.on('click', function() {
+ stopBodyScrolling(true); $pageRoot.addClass('show-sidebar');
+ });
+ $sidebarHide.on('click', function() {
+ stopBodyScrolling(false); $pageRoot.removeClass('show-sidebar');
+ });
+ });
+})();