Skip to content

Commit 90a8383

Browse files
author
Secretariat
committed
Carousel readme
1 parent ee292db commit 90a8383

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

3D Carousel/script.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ document.onpointerdown = function (e) {
9090

9191
document.onmousewheel = function (e) {
9292
e = e || window.event;
93-
console.log(e.wheelDelta, e.detail);
9493
var d = e.wheelDelta / 20 || -e.detail;
9594
radius += d;
9695
init(1);

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All animations were inspired and implemented by CodePen.
55
- [Table of contents](#table-of-contents)
66
- [3D Card](#3d-card)
77
- [CSS](#css)
8+
- [3D Carousel](#3d-carousel)
9+
- [Start Effect](#start-effect)
10+
- [Image 3D Effect](#image-3d-effect)
11+
- [Mouse Event Effect](#mouse-event-effect)
812

913
## Table of contents[](#table-of-contents)
1014
- 3D Card
@@ -21,4 +25,73 @@ This project is a project that implements a 3D card using CSS.
2125
-webkit-box-shadow: 2px 35px 32px -8px rgba(0, 0, 0, 0.75);
2226
-moz-box-shadow: 2px 35px 32px -8px rgba(0, 0, 0, 0.75);
2327
}
28+
```
29+
30+
## 3D Carousel[](#3d-carousel)
31+
<img align="center" src="/screenshot/3D_Carousel/Carousel.jpg" alt="3D_Carousel" style="width:100%;height:100%"/>
32+
This project is a project that implements the image carousel effect using CSS and JavaScript.
33+
34+
### Start Effect
35+
```
36+
for (var i = 0; i < imgs.length; i++) {
37+
imgs[i].style.transform = "rotateY(" + i * (360 / imgs.length) + "deg) translateZ(" + radius + "px)";
38+
imgs[i].style.transition = "transform 1s";
39+
imgs[i].style.transitionDelay = delayTime || (imgs.length - i) / 4 + "s";
40+
}
41+
```
42+
43+
### Image 3D Effect
44+
```
45+
img {
46+
transform-style: preserve-3d;
47+
position: absolute;
48+
left: 0;
49+
top: 0;
50+
width: 100%;
51+
height: 100%;
52+
line-height: 200px;
53+
font-size: 50px;
54+
text-align: center;
55+
box-shadow: 0 0 8px #fff;
56+
-webkit-box-reflect: below 10px linear-gradient(transparent, transparent, #0005);
57+
}
58+
```
59+
60+
### Mouse Event Effect
61+
```
62+
document.onpointerdown = function (e) {
63+
clearInterval(wheel.timer);
64+
e = e || window.event;
65+
var sX = e.clientX, sY = e.clientY;
66+
67+
this.onpointermove = function (e) {
68+
e = e || window.event;
69+
var nX = e.clientX, nY = e.clientY;
70+
desX = nX - sX;
71+
desY = nY - sY;
72+
tX += desX * 0.1;
73+
tY += desY * 0.1;
74+
applyTransform(wheel);
75+
sX = nX;
76+
sY = nY;
77+
};
78+
79+
this.onpointerup = function (e) {
80+
wheel.timer = setInterval(function () {
81+
desX *= 0.95;
82+
desY *= 0.95;
83+
tX += desX * 0.1;
84+
tY += desY * 0.1;
85+
applyTransform(wheel);
86+
playSpin(false);
87+
if (Math.abs(desX) < 0.5 && Math.abs(desY) < 0.5) {
88+
clearInterval(wheel.timer);
89+
playSpin(true);
90+
}
91+
}, 17);
92+
this.onpointermove = this.onpointerup = null;
93+
};
94+
95+
return false;
96+
};
2497
```

0 commit comments

Comments
 (0)