Difference between revisions of "Template:Team:Freiburg/wiki content start bubble"
Line 80: | Line 80: | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</style> | </style> | ||
Line 101: | Line 86: | ||
<script> | <script> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | $(document).ready(function(){ | |
− | + | var $blob = $('#bubble_wrapper>div'), | |
+ | $window = $(window), | ||
+ | $doc_heighttop = $(document).height() - $window.height(); | ||
− | $window. | + | //console.log('windowwidth:'+$window.width()); |
− | var | + | //console.log('windowheight:'+$window.height()); |
− | + | ||
− | + | $(window).scroll(function(event) { | |
+ | if ($window.width() > 1144) { | ||
+ | // y is scroll progress (distance from top) | ||
+ | // top is about bottomline of window | ||
+ | var y = $(this).scrollTop(), | ||
+ | top = $(this).scrollTop() + $window.height() -100; | ||
+ | //console.log($(this).scrollTop()+' doc_heighttop:'+$doc_heighttop+' top:'+top); | ||
+ | |||
+ | // use CSS transform to move button into view when user scrolls down | ||
+ | if (y > 60 ) { | ||
+ | //console.log('blob inside'); | ||
+ | $blob.css({"display":"inline", "transform": "translateY(0)"}); // = 30 px inside right | ||
+ | } | ||
+ | |||
+ | // move blob out of view when page is scrolled up again | ||
+ | if (y < 60) { | ||
+ | //console.log('blob outside'); | ||
+ | $blob.css({"transform": "translateY(130px)"}); // = 100 px outside | ||
+ | } | ||
+ | // define position of blob relative to page top, increases dynamically with scrolling | ||
+ | $blob.css({"top": top }); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} else { | } else { | ||
− | $ | + | $blob.css({"display": "none" }); // if page is too small, no blob is displayed |
− | + | ||
− | + | ||
− | + | ||
} | } | ||
}); | }); | ||
− | }); | + | |
− | + | $(window).resize(function(){ | |
+ | if ($window.width() < 1144) { | ||
+ | $blob.css({"display": "none" }); // if the user resizes the window when the blob is displayed | ||
+ | } | ||
+ | }); | ||
+ | }); | ||
+ | |||
+ | |||
</script> | </script> | ||
Line 155: | Line 151: | ||
</div> | </div> | ||
− | + | <div class="background_image_left"><img src="https://static.igem.org/mediawiki/2015/8/85/Freiburg_wiki_background_2_parted_left.png"></div> | |
− | + | <div class="background_image_right"><img src="https://static.igem.org/mediawiki/2015/f/f4/Freiburg_wiki_background_2_parted_right.png"></div> | |
<div class="page_content"> | <div class="page_content"> | ||
</html> | </html> |
Revision as of 13:28, 18 September 2015