Skip to content

Commit 9299e5e

Browse files
committed
Image Slider click-to-slide option
1 parent 60c2ff6 commit 9299e5e

File tree

6 files changed

+37
-10
lines changed

6 files changed

+37
-10
lines changed

dist/cssonly.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cssonly",
33
"description": "",
4-
"version": "0.0.18",
4+
"version": "0.0.19",
55
"main": "dist/cssonly.css",
66
"devDependencies": {
77
"autoprefixer": "^9.8.8",

src/image-comparison/style.scss

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
position: relative;
88
width: var(--width);
99
height: var(--height);
10+
user-select: none;
1011

1112
> * {
1213
max-width: 100%;

src/image-slider/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<link type="text/css" rel="stylesheet" href="/dist/cssonly.css" />
1212

1313
<div id="app" style="text-align: center;">
14-
<div class="cssonly-slider">
14+
<div class="cssonly-slider click-to-slide">
1515
<input type="radio" name="cssonly-slider" id="slide-1" />
1616
<input type="radio" name="cssonly-slider" id="slide-2" />
1717
<input type="radio" name="cssonly-slider" id="slide-3" />

src/image-slider/style.scss

+32-6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
.prev-arrows,
4949
.next-arrows {
5050
label {
51+
z-index: 1;
52+
5153
&::before {
5254
color: #aaa;
5355
font-size: 30px;
@@ -58,7 +60,7 @@
5860
width: 20px;
5961
text-align: center;
6062
line-height: 15px;
61-
z-index: 1;
63+
z-index: inherit;
6264
cursor: pointer;
6365
}
6466

@@ -79,11 +81,33 @@
7981
right: -30px;
8082
}
8183

82-
&:first-of-type::before {
84+
&:first-of-type {
8385
z-index: 2;
8486
}
8587
}
8688

89+
&.click-to-slide {
90+
.prev-arrows,
91+
.next-arrows {
92+
label::after {
93+
content: "";
94+
position: absolute;
95+
top: 0;
96+
bottom: 0;
97+
width: 50%;
98+
z-index: inherit;
99+
}
100+
}
101+
102+
.prev-arrows label::after {
103+
left: 0;
104+
}
105+
106+
.next-arrows label::after {
107+
right: 0;
108+
}
109+
}
110+
87111
.dots {
88112
position: absolute;
89113
bottom: 8px;
@@ -93,8 +117,9 @@
93117
display: flex;
94118
align-items: center;
95119
justify-content: center;
96-
z-index: 1;
120+
z-index: 2;
97121
opacity: 0.9;
122+
pointer-events: none;
98123

99124
label {
100125
position: relative;
@@ -107,6 +132,7 @@
107132
margin-right: 6px;
108133
cursor: pointer;
109134
transition: opacity 0.2s;
135+
pointer-events: all;
110136

111137
&:last-child {
112138
margin-right: 0;
@@ -141,7 +167,7 @@
141167

142168
&:indeterminate {
143169
~ .next-arrows {
144-
label:nth-of-type(2)::before {
170+
label:nth-of-type(2) {
145171
z-index: 2;
146172
}
147173
}
@@ -167,13 +193,13 @@
167193
}
168194

169195
~ .prev-arrows {
170-
label:nth-of-type(#{$i - 1})::before {
196+
label:nth-of-type(#{$i - 1}) {
171197
z-index: 2;
172198
}
173199
}
174200

175201
~ .next-arrows {
176-
label:nth-of-type(#{$i + 1})::before {
202+
label:nth-of-type(#{$i + 1}) {
177203
z-index: 2;
178204
}
179205
}

0 commit comments

Comments
 (0)