Ver Fonte

fixed footer

anatoly há 6 anos atrás
pai
commit
d9c0fb1714
1 ficheiros alterados com 26 adições e 17 exclusões
  1. 26 17
      src/files/js/script.js

+ 26 - 17
src/files/js/script.js

@@ -1,3 +1,11 @@
+function setFooterHeight() {
+    $('body').css('padding-bottom', $("footer").outerHeight());
+}
+
+$(window).resize(function () {
+    setFooterHeight();
+});
+
 $(document).ready(function () {
 
     $('.menu .burger').on('click', function () {
@@ -35,17 +43,17 @@ $(document).ready(function () {
         }
     });
 
-    $('#searchToggle').click(function(e) {
+    $('#searchToggle').click(function (e) {
         e.preventDefault();
         $("#searchForm").toggleClass('header-search--active')
     });
     let personal_list = $('.personals__tile-list');
-    if(personal_list.length){
+    if (personal_list.length) {
         let personal_title = $('.personals__tile').find('.personals__position');
         var title_heigh = 0;
-        $.each(personal_title,function(index, value){
+        $.each(personal_title, function (index, value) {
             let temp_height = $(value).height();
-            if(title_heigh < temp_height){
+            if (title_heigh < temp_height) {
                 title_heigh = temp_height;
             }
         });
@@ -63,13 +71,14 @@ $(document).ready(function () {
             $content.slideToggle();
         });
     })($);
+    setFooterHeight();
 });
-$(window).on('load',function(){
-    (function($){
+$(window).on('load', function () {
+    (function ($) {
         var body = $('html, body');
         var _bodyHeight = undefined;
-        const getBodyHeight = function() {
-            if(_bodyHeight === undefined) {
+        const getBodyHeight = function () {
+            if (_bodyHeight === undefined) {
                 _bodyHeight = $('body').outerHeight() || $('html').outerHeight();
             }
             return _bodyHeight;
@@ -78,11 +87,11 @@ $(window).on('load',function(){
         const footerHeight = 333;
         const scrollOffset = 30;
         const scrollToShow = 400;
-        const getScroll = function() {
+        const getScroll = function () {
             return $('body').scrollTop() || $('html').scrollTop();
         };
-        const getButtonPos = function() {
-            if(getScroll() + windowHeight > getBodyHeight() - footerHeight) {
+        const getButtonPos = function () {
+            if (getScroll() + windowHeight > getBodyHeight() - footerHeight) {
                 const currentScroll = (getScroll() + windowHeight);
                 const bodyFooter = (getBodyHeight() - footerHeight);
                 return (scrollOffset + (currentScroll - bodyFooter));
@@ -91,26 +100,26 @@ $(window).on('load',function(){
             }
         };
 
-        if(body.height() > windowHeight && body.width() > 1023) {
+        if (body.height() > windowHeight && body.width() > 1023) {
             var button = $('<div class="go-top-link"></div>')
                 .css({
                     'position': 'fixed',
                     'bottom': getButtonPos() + 'px',
                     'left': '30px'
-                }).click(function(){
+                }).click(function () {
                     body.animate({'scrollTop': 0});
                 }).hide();
             body.append(button);
             var isShown = false;
-            if(getScroll() >= scrollToShow) {
+            if (getScroll() >= scrollToShow) {
                 button.fadeIn();
                 isShown = true;
             }
-            $(window).on('scroll', function(){
-                if(getScroll() >= scrollToShow && !isShown) {
+            $(window).on('scroll', function () {
+                if (getScroll() >= scrollToShow && !isShown) {
                     button.stop().fadeIn();
                     isShown = true;
-                } else if(getScroll() < scrollToShow && isShown) {
+                } else if (getScroll() < scrollToShow && isShown) {
                     button.stop().fadeOut();
                     isShown = false;
                 }