aboutsummaryrefslogtreecommitdiff
path: root/mod/magic_topbar/views/default/magic_topbar/js.php
blob: cb51913f3c50f49629c5fd62ad0f811c0b8c9506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
 * Hide the topbar when no using with an animation.
 *
 * @package ElggMagicTopbar
 */
?>

$(function() {

	var $topbar   = $(".elgg-page-topbar"),
		$window   = $(window);

	$topbar.css({position: 'fixed', width: '100%'});

	$window.scroll(function() {
		$topbar.stop();
		var opacity;
		if ($window.scrollTop() > 14) {
			$topbar.animate({opacity: 0}, 'fast');
		} else {
			$topbar.css({opacity: 1});
		}
	});

	$topbar.mouseenter(function(){
		$topbar.stop();
		$topbar.animate({opacity: 1});
	})
	.mouseleave(function(){
		$topbar.stop();
		var opacity;
		if ($window.scrollTop() > 14) {
			opacity = 0;
		} else {
			opacity = 1;
		}
		$topbar.animate({opacity: opacity});
	});
});