-
Notifications
You must be signed in to change notification settings - Fork 0
/
sport.js
67 lines (53 loc) · 1.96 KB
/
sport.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
$(document).ready(function() {
$('.badminton_image').mouseenter(function(){
$(this).css('width','300px');
$(this).css('height','300px');
})
})
$(document).ready(function() {
$('.badminton_image').mouseleave(function(){
$(this).css('width','240px');
$(this).css('height','240px');
})
})
//一閃一閃的效果
$(document).ready(function() {
setInterval(function() {$('.Taekwondo_image').toggleClass('shinning_Taekwondo');}, 1000);
})
$(document).ready(function() {
setInterval(function() {$('.table_image').toggleClass('shinning');}, 1000);
setInterval(function() {$('.Weightlifting_image').toggleClass('shinning');}, 1000);
})
//淡入特效
$(document).ready(function() {
$('badminton_image').fadeIn(2000); // 在2秒內淡入
});
/*頁面滾動時:照片特效(左右滑入,淡入)*/
$(document).ready(function() {
function checkIfInView() {
$('.fade').each(function() {
var element = $(this);
var elementTop = element.offset().top;
var elementBottom = elementTop + element.outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
if (elementBottom > viewportTop && elementTop < viewportBottom) {
element.addClass('in-view');
}
});
$('.Weightlifting_image').each(function() {
var element = $(this);
var elementTop = element.offset().top;
var elementBottom = elementTop + element.outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + $(window).height();
if (elementBottom > viewportTop && elementTop < viewportBottom) {
element.addClass('appear-view');
}
});
}
$(window).on('scroll resize', function() {
checkIfInView();
});
checkIfInView();
});