-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflip.js
73 lines (67 loc) · 2.06 KB
/
flip.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
71
72
73
$(document).ready(function() {
function flip() {
// 初始化
$(".flip").each(function(index) {
var _this = $(this);
_this.css({
'height': _this.children(".front").height()
});
});
// 打开
function open(element) {
element.removeClass("flipToFront");
element.addClass("flipToBack");
setTimeout(function() {
element.children(".front").hide();
}, 300)
element.css({
'height': element.children(".back").height()
});
setTimeout(function() {
element.children(".back").show();
element.animatescroll({
scrollSpeed: 1500,
padding: 60,
onScrollEnd: function() {}
});
}, 200)
}
// 关闭
function close(element) {
element.removeClass("flipToBack");
element.addClass("flipToFront");
setTimeout(function() {
element.children(".back").hide();
}, 250);
element.css({
'height': element.children(".front").height()
});
setTimeout(function() {
element.children(".front").show();
}, 200);
}
// 点击响应
var _oldthisnum = -1;
var isopen = 0;
$(".flip").click(function() {
var _this = $(this);
if (isopen == 0) {
open(_this);
isopen = 1;
_oldthisnum = _this.index();
} else {
if (_oldthisnum == _this.index()) {
close(_this);
isopen = 0;
} else {
close($(".flip").eq(_oldthisnum));
setTimeout(function() {
open(_this);
}, 510);
}
_oldthisnum = _this.index();
}
});
}
flip();
});