Front fun

ReZero lol

light card

Talk is cheap, note is there , show you code.

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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html>

<head>
<title></title>
<meta charset="utf-8" />
<style media="screen">
body{
background-color: #000;
}
#wrap{
position: relative;
/*the img size and make it get center*/
width: 130px;
height: 200px;
margin: 150px auto;
transform-style: preserve-3d;
/*perspective: 1000px;*/
/*make the whole items of wrap rotate by the axis */
/*perspective, which between 800 and 1000 seems better.*/
transform: perspective(1000px) rotateX(-10deg) rotateY(0deg);

}
#wrap>div{
position: absolute;
transition:1s;
}
#wrap img{
/*delete the break between img*/
vertical-align: middle;
/*x-offset y-offset spread-offset color*/
box-shadow: 0 0 10px #fff;
}
/*the inverted img was created*/
#wrap div div{
height: 200px;
margin-top: 10px;
/*reverse by y axis */
transform: scale(1,-1);
background: linear-gradient(rgb(0,0,0) 40%,rgba(0,0,0,0)),url(img/10.jpg);

}

#wrap span{
display: block;
width:1200px;
height:1200px;
position: absolute;
/*center span*/
left:50%;
top:50%;
margin-left:-600px;
margin-top:-600px;

background: radial-gradient(rgb(50,50,50), rgba(0,0,0,0) 70%);
transform: translateY(110px) rotateX(90deg);

}


</style>
<script >
window.onload=function () {
let wrap=document.getElementById("wrap");
let divs=document.querySelectorAll("#wrap>div");
let refs=document.querySelectorAll("#wrap div div");
let rotate=360/divs.length;

for(let i=0;i<divs.length;i++){
// the inverted img
refs[i].style.background='linear-gradient(rgb(0,0,0) 40%,rgba(0,0,0,0)),url(img/'+(i+1)+'.jpg)';
// anonymous function and closure
(function(i){
setTimeout(function(){
// After 2000, 1800, 1600 ... seconds to run transform(1s)
// The first page was last runner
divs[i].style.transform='rotateY('+i*rotate+'deg) translateZ(400px)';
},(divs.length-i)*200);
})(i);
}

// When the fist img was run at the end position
divs[0].addEventListener('transitionend',function(){
drag();
});

function drag(){
let curX=0; //init circle value
let curY=-10; //init circle value
let timer;

document.onmousedown=function(ev){
clearInterval(timer);
let startTime=new Date().getTime(); //when you mouse down
let disX=ev.clientX; //the start point
let disY=ev.clientY; //the start point

/*
* Last stop point
* Every mouse down need set the lastXY
*/
let lastX=curX;
let lastY=curY;

/*note the speed*/
let speedX=0;
let speedY=0;

document.onmousemove=function(ev){
curX=lastX+(ev.clientX-disX)/10;
curY=lastY+(disY-ev.clientY)/10;

wrap.style.transform='perspective(1000px) rotateX('+curY+'deg) rotateY('+curX+'deg)';

//drag distance by the mouse move distance
//so you need calc the
speedX=(ev.clientX-disX)/100;
speedY=(disY-ev.clientY)/100;
};

document.onmouseup=function(){
document.onmousemove=null;
let endTime=new Date().getTime(); //note the mouse up time

if(endTime-startTime<300){
timer=setInterval(function(){
curX+=speedX;
curY+=speedY;

//friction force
speedX*=0.95;
speedY*=0.95;

//stop condition
if(Math.abs(speedX)<0.1 && Math.abs(speedY)<0.1){
clearInterval(timer);
}

wrap.style.transform='perspective(1000px) rotateX('+curY+'deg) rotateY('+curX+'deg)';
},16);
}
};

return false;
};
}



}
</script>

</head>
<body>
<div id="wrap">
<div><img src="img/1.jpg" />
<div>

</div>
</div>
<div><img src="img/2.jpg" />
<div >

</div>
</div>
<div><img src="img/3.jpg" />
<div >

</div>
</div>
<div><img src="img/4.jpg" />
<div>

</div>
</div>

<div><img src="img/5.jpg" />
<div>

</div>
</div>
<div><img src="img/6.jpg" />
<div>

</div>
</div>
<div><img src="img/7.jpg" />
<div>

</div>
</div>
<div><img src="img/8.jpg" />
<div>

</div>
</div>
<div><img src="img/9.jpg" />
<div>

</div>
</div>
<div><img src="img/10.jpg" />
<div>

</div>
</div>
<span></span>
</div>
</body>

</html>

Css

Css Diner

Select what you want.

  1. A + B This selects all B elements that directly follow A. Elements that follow one another are called siblings. They’re on the same level, or depth. In the HTML markup for this level, elements that have the same indentation are siblings. Examples p + .intro selects every element with class=”intro” that directly follows a p div + a selects every a element that directly follows a <div>

  2. A ~ B You can select all siblings of an element that follow it. This is like the Adjacent Selector (A + B) except it gets all of the following elements instead of one. Examples A ~ B selects all B that follow a A

  3. A > B You can select elements that are direct children of other elements. A child element is any element that is nested directly in another element. Elements that are nested deeper than that are called descendant elements. Examples A > B selects all B that are a direct children A

  4. :nth-of-type[An+B] The nth-of-type formula selects every nth element, starting the count at a specific instance of that element. Examples span:nth-of-type(6n+2) selects every 6th instance of a span, starting from (and including) the second instance.

  5. :empty Selects elements that don’t have any other elements inside of them. Examples div:empty selects all empty div elements.

  6. :not(X) You can use this to select all elements that do not match selector “X”. Examples :not(#fancy) selects all elements that do not have id=”fancy”. div:not(:first-child) selects every div that is not a first child. :not(.big, .medium) selects all elements that do not have class=”big” or class=”medium”.

  7. [attribute=”value”]* A useful selector if you can identify a common pattern in things like class, href or src attributes. Examples img[src*="/thumbnails/"] selects all image elements that show images from the "thumbnails" folder.

    [class*="heading"] selects all elements with “heading” in their class, like class="main-heading" and class="sub-heading".

  • Post title:Front fun
  • Post author:ReZero
  • Create time:2017-07-09 21:16:00
  • Post link:https://rezeros.github.io/2017/07/09/front-fun/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments