/
jquery.lava.js
executable file
·69 lines (34 loc) · 1.11 KB
/
jquery.lava.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(function($) {
$.fn.lava = function(options) {
var that = this;
var settings = {
container: '#navigation',
cursor: '#lava-cursor',
current: '.current',
speed: 800
};
options = $.extend(settings, options);
return that.each(function() {
if($(options.current, $(options.container)).length) {
$(options.cursor).css('left', $(options.container).find(options.current).position().left).fadeIn(options.speed);
} else {
$(options.cursor).fadeIn(options.speed);
}
$('li', $(options.container)).each(function() {
var $li = $(this);
$li.mouseover(function() {
$(options.cursor).stop(true, true).animate({
left: $li.position().left
}, options.speed);
});
$li.mouseout(function() {
if($(options.current, $(options.container)).length) {
$(options.cursor).stop(true, true).animate({
left: $(options.current, $(options.container)).position().left
}, options.speed);
}
});
});
});
};
})(jQuery);