-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallax.js
70 lines (61 loc) · 1.9 KB
/
parallax.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
70
jQuery(document).ready(function(){
$('.bgParallax').parallaxbg();
$('#parallax').mousemove(
function(e){
var offset = $(this).offset();
var xpos = e.pageX - offset.left;
var ypos = e.pageY - offset.top;
var mousex = Math.round(xpos / $(this).width()*100);
var mousey = Math.round(ypos / $(this).height()*100);
$(this).children('.bola').each(
function(){
var difx = $('#parallax').width() - $(this).width();
var dify = $('#parallax').height() - $(this).height();
var novox = difx * (mousex / 100);
var novoy = dify * (mousey / 100);
$(this).animate({left: novox, top: novoy},{duration: 50, queue: false, easing: 'linear'});
}
);
}
);
$('#parallax-bg').mousemove(function(e){
var offset = $(this).offset();
var xpos = e.pageX - offset.left;
var ypos = e.pageY - offset.top;
var mousex = Math.round(xpos / $(this).width()*100);
var mousey = Math.round(ypos / $(this).height()*100);
var bg = -mousex + 'px ' + -mousey + "px";
$(this).css('background-position',bg);
});
/*$('div.bgParallax').each(function(){
var $obj = $(this);
$(window).scroll(function() {
var yPos = -($(window).scrollTop() / $obj.data('speed'));
var bgpos = '50% '+ yPos + 'px';
$obj.css('background-position', bgpos );
});
});*/
(function( $ ){
$.fn.tooltip = function(options) {
var defaults = {
'corDeFundo' : 'yellow'
};
var settings = $.extend( {}, defaults, options );
return this.each(function() {
$(this).css({ background: settings.corDeFundo });
});
};
})( jQuery );
});
(function ($){
$.fn.parallaxbg = function(){
return this.each(function(){
var obj = $(this);
$(window).scroll(function(){
var yPos = -($(window).scrollTop() / obj.data('speed'));
var bgpos = '50% '+ yPos + 'px';
obj.css('background-position',bgpos);
});
});
};
})(jQuery);