From 7bc4f803402be78ca9bfa9354e8ddc47a571b6d1 Mon Sep 17 00:00:00 2001 From: William Mantly Date: Thu, 15 Aug 2024 18:44:46 -0400 Subject: [PATCH] Added scrollTo function in JS base app --- nodejs/public/lib/js/app-base.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/nodejs/public/lib/js/app-base.js b/nodejs/public/lib/js/app-base.js index 33511e0..486cb0c 100644 --- a/nodejs/public/lib/js/app-base.js +++ b/nodejs/public/lib/js/app-base.js @@ -363,7 +363,12 @@ $( document ).ready(function(){ }); $('.fa-circle-minus').click(function(){ - $(this).closest('.card').find('.card-body').slideToggle('fast'); + let $body = $(this).closest('.card').find('.card-body'); + if($body.hasClass('d-none')){ + $body.removeClass("d-none").removeClass('d-md-block'); + if($body.is(":visible")) $body.hide(); + } + $body.slideToggle('fast'); }); $('.fa-circle-xmark').click(function(){ @@ -384,6 +389,17 @@ $( document ).ready(function(){ }, 30000,); }); +(function($){ + $.fn.scrollTo = function(){ + const yOffset = Number($('#spa-shell').css('margin-top').replace('px', '')); + const y = this[0].getBoundingClientRect().top + window.scrollY - yOffset; + + console.log('y', y) + window.scrollTo({top: y, behavior: 'smooth'}); + }; + +})(jQuery); + //ajax form submit function formAJAX(btn){ event.preventDefault(btn); // avoid to execute the actual submit of the form.