|
|
@@ -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');
|
|
|
});
|
|
|
}
|
|
|
})($)
|
|
|
-});
|
|
|
-
|
|
|
+});
|