-
Notifications
You must be signed in to change notification settings - Fork 54
/
_carousel.scss
339 lines (287 loc) · 8.93 KB
/
_carousel.scss
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
// Notes on the classes:
//
// 1. .carousel.pointer-event should ideally be pan-y (to allow for users to scroll vertically)
// even when their scroll action started on a carousel, but for compatibility (with Firefox)
// we're preventing all actions instead
// 2. The .carousel-item-start and .carousel-item-end is used to indicate where
// the active slide is heading.
// 3. .active.carousel-item is the current slide.
// 4. .active.carousel-item-start and .active.carousel-item-end is the current
// slide in its in-transition state. Only one of these occurs at a time.
// 5. .carousel-item-next.carousel-item-start and .carousel-item-prev.carousel-item-end
// is the upcoming slide in transition.
.carousel {
position: relative;
}
.carousel.pointer-event {
touch-action: pan-y;
}
.carousel-inner {
position: relative;
width: 100%;
overflow: hidden;
@include clearfix();
}
.carousel-item {
position: relative;
display: none;
float: left;
width: 100%;
margin-right: -100%;
backface-visibility: hidden;
@include transition($carousel-transition);
}
.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
display: block;
}
/* rtl:begin:ignore */
.carousel-item-next:not(.carousel-item-start),
.active.carousel-item-end {
transform: translateX(100%);
}
.carousel-item-prev:not(.carousel-item-end),
.active.carousel-item-start {
transform: translateX(-100%);
}
/* rtl:end:ignore */
//
// Alternate transitions
//
.carousel-fade {
.carousel-item {
opacity: 0;
transition-property: opacity;
transform: none;
}
.carousel-item.active,
.carousel-item-next.carousel-item-start,
.carousel-item-prev.carousel-item-end {
z-index: 1;
opacity: 1;
}
.active.carousel-item-start,
.active.carousel-item-end {
z-index: 0;
opacity: 0;
@include transition(opacity 0s $carousel-transition-duration);
}
}
//
// Left/right controls for nav
//
.carousel-control-prev,
.carousel-control-next {
--#{$boosted-prefix}control-bg: #{rgba($carousel-indicator-active-bg, .5)}; // Boosted mod
position: absolute;
top: 0;
bottom: 0;
z-index: 1;
// Use flex for alignment (1-3)
display: flex; // 1. allow flex styles
align-items: center; // 2. vertically center contents
justify-content: center; // 3. horizontally center contents
width: $carousel-control-width;
padding: 0;
color: $carousel-control-color;
text-align: center;
background: none;
border: 0;
outline: 0; // Boosted mod
opacity: $carousel-control-opacity;
@include transition($carousel-control-transition);
// Hover/focus state
&:hover,
&:focus {
--#{$boosted-prefix}control-bg: #{color-contrast($carousel-indicator-active-bg)}; // Boosted mod
color: color-contrast($carousel-control-color);
text-decoration: none;
opacity: $carousel-control-hover-opacity;
}
// Boosted mod
&:disabled,
&[aria-disabled] {
color: $gray-700;
pointer-events: none;
}
&:active {
--#{$boosted-prefix}control-bg: #{$carousel-control-icon-active-bg};
color: $carousel-control-color;
}
&:focus {
&[data-focus-visible-added] {
& > span {
outline: map-get($border-widths, 3) solid $brand-orange;
outline-offset: $outline-offset;
box-shadow: 0 0 0 $outline-offset $white;
}
}
}
// End mod
}
.carousel-control-prev {
left: 0;
background-image: if($enable-gradients, linear-gradient(90deg, rgba($black, .25), rgba($black, .001)), null);
}
.carousel-control-next {
right: 0;
background-image: if($enable-gradients, linear-gradient(270deg, rgba($black, .25), rgba($black, .001)), null);
}
// Icons for within
.carousel-control-prev-icon,
.carousel-control-next-icon {
display: inline-block;
background-color: var(--#{$boosted-prefix}control-bg); // Boosted mod
@include button-icon($carousel-control-icon-bg, $carousel-control-icon-width, $size: $carousel-control-icon-size, $position: subtract(50%, $spacer * .1) 50%); // Boosted mod
@include border-radius(50%, 50%);
}
// Boosted mod
/* rtl:begin:remove */
.carousel-control-next-icon {
transform: scaleX(-1);
}
/* rtl:end:remove */
/* rtl:raw:
.carousel-control-prev-icon {
transform: scaleX(-1);
}
*/
// End mod
// Optional indicator pips/controls
//
// Add a container (such as a list) with the following class and add an item (ideally a focusable control,
// like a button) with data-bs-target for each slide your carousel holds.
/* rtl:begin:ignore */
.carousel-indicators {
position: absolute;
bottom: 0;
left: 50%; // Boosted mod
z-index: 2;
display: flex;
justify-content: center;
padding: $carousel-indicators-padding-y 0; // Boosted mod
margin-bottom: $spacer; // Boosted mod
list-style: none;
background: rgba($carousel-indicator-active-bg, .5); // Boosted mod
transform: translateX(-50%); // Boosted mod
@include border-radius($spacer, $spacer); // Boosted mod
[data-bs-target] {
box-sizing: content-box;
flex: 0 1 auto;
width: $carousel-indicator-width;
height: $carousel-indicator-height;
padding: 0;
margin-right: $carousel-indicator-spacer;
margin-left: $carousel-indicator-spacer;
text-indent: -999px;
cursor: pointer;
background-color: $carousel-control-color; // Boosted mod
border: 0;
// Boosted mod: use our own target-size() mixin instead of transparent borders
opacity: $carousel-indicator-opacity;
@include transition($carousel-indicator-transition);
// Boosted mod
@include border-radius(50%, 50%);
@include target-size($carousel-indicator-hit-area-height);
&:hover,
&:focus {
background-color: color-contrast($carousel-indicator-active-bg);
}
&:hover {
transform: scale($carousel-indicator-hover-scale);
&::before {
transform: translate3d(-50%, -50%, 0) scale($carousel-indicator-active-scale);
}
}
&:focus {
&[data-focus-visible-added] {
outline: map-get($border-widths, 3) solid $brand-orange;
outline-offset: $outline-offset;
box-shadow: 0 0 0 $outline-offset $white;
transform: none;
}
}
}
.active {
background-color: $carousel-indicator-active-bg;
border-color: color-contrast($carousel-indicator-active-bg);
opacity: $carousel-indicator-active-opacity;
@if $enable-transitions {
// Animation based on Lea Verou's simple pie chart
// See https://www.smashingmagazine.com/2015/07/designing-simple-pie-charts-with-css/
background-image: linear-gradient(to right, transparent 50%, color-contrast($carousel-indicator-active-bg) 0);
transform: scale($carousel-indicator-hover-scale);
// No need to feature test mask-*
// See https://caniuse.com/mdn-css_properties_mask-image
mask-image: radial-gradient(circle at 50%, transparent 33%, $white add(33%, 1px));
&:hover,
&:focus {
mask-image: none;
}
&::before {
transform: translate3d(-50%, -50%, 0) scale($carousel-indicator-active-scale);
}
&::after {
position: absolute;
top: 0;
left: 50%;
width: 50%;
height: 100%;
content: "";
background-color: inherit;
transform-origin: left;
// stylelint-disable-next-line function-disallowed-list
animation: carousel-progress calc(#{$carousel-indicator-animation-interval} / 2) linear infinite, carousel-progress-half $carousel-indicator-animation-interval step-end infinite;
@include border-radius($carousel-indicator-active-radius, $carousel-indicator-active-radius);
}
@keyframes carousel-progress {
to { transform: rotate(.5turn); }
}
@keyframes carousel-progress-half {
50% { background: color-contrast($carousel-indicator-active-bg); }
}
.carousel.is-done &,
.carousel.is-paused &,
.carousel.is-static & {
background: color-contrast($carousel-indicator-active-bg);
&::after {
animation: none;
}
}
@if $enable-reduced-motion {
@media (prefers-reduced-motion: reduce) {
background: color-contrast($carousel-indicator-active-bg);
&::after {
animation: none;
}
}
}
}
}
}
/* rtl:end:ignore */
// End mod
// Optional captions
//
//
.carousel-caption {
position: absolute;
right: (100% - $carousel-caption-width) * .5;
bottom: $carousel-caption-spacer;
left: (100% - $carousel-caption-width) * .5;
padding: $carousel-caption-padding-y $carousel-caption-padding-x; // Boosted mod
color: $carousel-caption-color;
background-color: color-contrast($carousel-caption-color); // Boosted mod: ensure contrast
}
// Boosted mod: no dark carousel
// Boosted mod: play/pause button
.carousel-control-play-pause {
&.pause {
@include button-icon($carousel-control-pause-icon, $size: $carousel-control-pause-icon-size, $pseudo: "after");
}
&.play {
@include button-icon($carousel-control-play-icon, $size: $carousel-control-pause-icon-size, $pseudo: "after");
}
}
// End mod