Difference between revisions of "Template:Freiburg/wiki content start"
Line 1: | Line 1: | ||
<html> | <html> | ||
+ | |||
+ | <!-- UPWARDS BLOB JQUERY --> | ||
<script> | <script> | ||
+ | |||
+ | // The upwards-blob div is defined in Freiburg/CSS as its absolute position should be initialized on the top of the page | ||
$(document).ready(function(){ | $(document).ready(function(){ | ||
Line 8: | Line 12: | ||
$pageheight = $(document).height()-$window.height(); | $pageheight = $(document).height()-$window.height(); | ||
− | console.log('pageheight:'+$pageheight); | + | //console.log('pageheight:'+$pageheight); |
− | console.log('windowwidth:'+$window.width()); | + | //console.log('windowwidth:'+$window.width()); |
− | console.log('windowheight:'+$window.height()); | + | //console.log('windowheight:'+$window.height()); |
$(window).scroll(function(event) { | $(window).scroll(function(event) { | ||
− | + | //console.log($(this).scrollTop()+' pageheight:'+$pageheight); | |
− | + | ||
− | + | ||
− | + | // y is scroll progress (distance from top) | |
− | + | // top is abbout bottomline of window | |
− | + | var y = $(this).scrollTop(), | |
− | + | top = $(this).scrollTop() + $window.height() -100; | |
− | + | ||
− | + | // use CSS transform to move button into view when user scrolls down | |
− | + | if (y > 60 ) { | |
− | + | //console.log('right out'); | |
− | + | $blob.css({"transform": "translateX(-130px)"}); // = 30 px inside right | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | / | + | // move blob out of view when page is scrolled up again |
− | + | if (y < 60) { | |
− | + | //console.log('right in'); | |
− | + | $blob.css({"transform": "translateX(0)"}); // = 100 px outside | |
− | console.log(' | + | |
− | $blob.css({"transform":" | + | |
} | } | ||
− | |||
− | + | // offset of the button on the bottom of the page depends on the background image and thus the page-width | |
− | + | // for pages smaller than 1143 px the button disappears by media queries (found in Freiburg/CSS) | |
− | if ($window. | + | if ($window.width() < 1320) { |
− | console.log(' | + | if (y > ($pageheight - 100)) { |
− | + | // blob stays 100px above bottom | |
− | if ($window. | + | //console.log("y 100 up"); |
− | console.log( | + | } else { |
− | + | //console.log('y in window'); | |
− | + | $blob.css({"top": top }); | |
− | + | } | |
− | + | } else if ($window.width() > 1320) { | |
− | + | if (y > ($pageheight - 500)) { | |
− | $blob. | + | //console.log("y 500 up"); |
− | + | } else { | |
− | + | //console.log('y in window'); | |
+ | $blob.css({"top": top }); | ||
} | } | ||
} | } | ||
− | + | }); | |
− | + | ||
− | + | ||
}); | }); | ||
Revision as of 07:33, 8 September 2015