Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ui_suite_bootstrap
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ui_suite_bootstrap
Commits
febe38ed
Commit
febe38ed
authored
5 months ago
by
Florent Torregrosa
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3484065
by grimreaper, pdureau: Carousel item: only add active on the first item.
parent
5389500a
No related branches found
No related tags found
1 merge request
!230
Issue #3484746 by grimreaper, pdureau: Use "is sequence" Twig test to prevent...
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/carousel/js/carousel.js
+6
-24
6 additions, 24 deletions
components/carousel/js/carousel.js
with
6 additions
and
24 deletions
components/carousel/js/carousel.js
+
6
−
24
View file @
febe38ed
((
Drupal
,
once
)
=>
{
Drupal
.
ui_suite_bootstrap_carousel
=
Drupal
.
ui_suite_bootstrap_carousel
||
{};
Drupal
.
ui_suite_bootstrap_carousel
=
Drupal
.
ui_suite_bootstrap_carousel
||
{};
/**
* Set active class.
* Set active class
on the first item
.
*
* @type {Drupal~behavior}
*
...
...
@@ -12,31 +11,14 @@
*/
Drupal
.
behaviors
.
ui_suite_bootstrap_carousel
=
{
attach
(
context
)
{
once
(
'
carousel-active
'
,
"
.carousel
"
,
context
,
).
forEach
((
carousel
)
=>
{
const
items
=
carousel
.
querySelectorAll
(
'
.carousel-inner .carousel-item
'
);
once
(
'
carousel-active
'
,
'
.carousel
'
,
context
).
forEach
((
carousel
)
=>
{
const
items
=
carousel
.
querySelectorAll
(
'
.carousel-inner .carousel-item
'
,
);
if
(
items
.
length
===
0
)
{
return
;
}
// Check if there is an item with the active class.
let
activeFound
=
false
;
items
.
forEach
(
function
(
item
)
{
if
(
activeFound
)
{
return
;
}
activeFound
=
item
.
classList
.
contains
(
'
active
'
);
});
if
(
activeFound
)
{
return
;
}
// If the carousel have no active items, put the active class on the
// first one.
items
.
item
(
0
).
classList
.
add
(
'
active
'
);
});
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment