Prechádzať zdrojové kódy

fix go-top-link footer offset, fix footer margin

alexlcdee 7 rokov pred
rodič
commit
6e61e3e58c
3 zmenil súbory, kde vykonal 30 pridanie a 9 odobranie
  1. 1 1
      src/files/css/main.css
  2. 28 7
      src/files/js/script.js
  3. 1 1
      src/files/scss/main.scss

+ 1 - 1
src/files/css/main.css

@@ -10793,7 +10793,7 @@ body {
   font-family: "Open Sans", Arial, "Helvetica CY", "Nimbus Sans L", sans-serif;
   min-height: 100vh;
   position: relative;
-  padding-bottom: 293px; }
+  padding-bottom: 333px; }
   body footer {
     bottom: 0; }
 

+ 28 - 7
src/files/js/script.js

@@ -39,24 +39,45 @@ $(document).ready(function () {
         e.preventDefault();
         $("#searchForm").toggleClass('header-search--active')
     });
-
+});
+$(window).on('load',function(){
     (function($){
         var body = $('html, body');
-        var getScroll = function() {
+        var _bodyHeight = undefined;
+        const getBodyHeight = function() {
+            if(_bodyHeight === undefined) {
+                _bodyHeight = $('body').outerHeight() || $('html').outerHeight();
+            }
+            return _bodyHeight;
+        };
+        const windowHeight = window.innerHeight;
+        const footerHeight = 333;
+        const scrollOffset = 30;
+        const scrollToShow = 400;
+        const getScroll = function() {
             return $('body').scrollTop() || $('html').scrollTop();
         };
-        if(body.height() > window.outerHeight && body.width() > 1023) {
+        const getButtonPos = function() {
+            if(getScroll() + windowHeight > getBodyHeight() - footerHeight) {
+                const currentScroll = (getScroll() + windowHeight);
+                const bodyFooter = (getBodyHeight() - footerHeight);
+                return (scrollOffset + (currentScroll - bodyFooter));
+            } else {
+                return scrollOffset;
+            }
+        };
+
+        if(body.height() > windowHeight && body.width() > 1023) {
             var button = $('<div class="go-top-link"></div>')
                 .css({
                     'position': 'fixed',
-                    'bottom': '30px',
+                    'bottom': getButtonPos() + 'px',
                     'left': '30px'
                 }).click(function(){
                     body.animate({'scrollTop': 0});
                 }).hide();
             body.append(button);
             var isShown = false;
-            var scrollToShow = 400;
             if(getScroll() >= scrollToShow) {
                 button.fadeIn();
                 isShown = true;
@@ -69,8 +90,8 @@ $(document).ready(function () {
                     button.stop().fadeOut();
                     isShown = false;
                 }
+                button.css('bottom', getButtonPos() + 'px');
             });
         }
     })($)
-});
-	
+});

+ 1 - 1
src/files/scss/main.scss

@@ -41,7 +41,7 @@ body {
     font-family: $fontopensans;
     min-height: 100vh;
     position: relative;
-    padding-bottom: 293px;
+    padding-bottom: 333px;
 
     footer {
         bottom: 0;