-
Notifications
You must be signed in to change notification settings - Fork 1
/
lunpo.js
115 lines (105 loc) · 2.17 KB
/
lunpo.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var container = e("#id-lunpo")
var photos = es("#id-lunpo .photo")
var position = [
{
x : -400,
y : 0,
z : -120,
},
{
x : -200,
y : 0,
z : -60,
},
{
x : 0,
y : 0,
z : 30,
},
{
x : 200,
y : 0,
z : -60,
},
{
x : 400,
y : 0,
z : -120,
}]
var playLunpoInterval = null
var nLunpo = 0
var playLunpo = function() {
clearInterval(playLunpoInterval)
playLunpoInterval = setInterval(function() {
nLunpo = changePos(nLunpo)
}, 3000)
}
var stopLunpo = function() {
clearInterval(playLunpoInterval)
}
var changePos = function(nLunpo) {
for(var i = 0; i < photos.length; i++) {
photos[i].style.transform = `translate3d(${position[nLunpo].x}px, ${position[nLunpo].y}px, ${position[nLunpo].z}px)`
nLunpo++
nLunpo %= photos.length
}
nLunpo++
nLunpo %= photos.length
return nLunpo
}
var indexOf = function(e) {
var id = e.id
var ids = id.split("-")
var index = parseInt(ids[ids.length - 1])
return index
}
var setPos = function(e) {
var event = e.target
var index = indexOf(event)
var pos = ((2 - index) + 5) % photos.length
log("index", index,"pos", pos)
nLunpo = changePos(pos)
AddFromLunbo(index)
}
var initLunpo = function() {
container.addEventListener("mouseover",function() {
clearInterval(playLunpoInterval)
})
container.addEventListener("mouseout",function() {
playLunpo()
})
container.addEventListener("click", setPos)
}
//设置背景
var setBackground = function() {
var lunpo = e('#id-lunpo')
var photos = findAll(lunpo, 'span')
for(var i = 0; i < photos.length; i++) {
var basePath = 'img/'
var music = onlineList[i]
var path = basePath + music.imgPath
photos[i].style.backgroundImage = `url(${path})`
var a = find(photos[i], 'a')
a.innerHTML = `${music.name}--${music.singer}`
}
}
//点击更新 播放列表 并播放
var AddFromLunbo = function(index) {
var addMusic = onlineList[index]
for(var i = 0; i < musicList.length; i++) {
var music = musicList[i].music
if(music == addMusic.music) {
log('播放列表已存在该歌曲')
CutPlay(musicList[i], i)
return
}
}
musicList.push(addMusic)
UpdateMusicList()
var n = musicList.length - 1
CutPlay(addMusic, n)
}
initLunpo()
playLunpo()
setBackground()
nLunpo = changePos(nLunpo)