Skip to content

Commit aaed859

Browse files
authored
Merge pull request #59 from eaudeweb/29044-homepage-carousel
refs#29044 add autoplay and autoplay speed options for carousel
2 parents 020281d + f7d9077 commit aaed859

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

modules/edw_paragraphs/modules/edw_paragraphs_carousel/components/slider/slider.component.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ props:
2626
title: Slider fade effect
2727
description: Slider fade effect, default -> false.
2828
default: false
29+
autoplay:
30+
type: boolean
31+
title: Autoplay
32+
description: Enables Autoplay
33+
default: false
34+
autoplaySpeed:
35+
type: integer
36+
title: Autoplay speed
37+
description: Autoplay speed in ms.
38+
default: true
2939

3040
slider_classes:
3141
type: array
@@ -47,5 +57,5 @@ slots:
4757
libraryOverrides:
4858
dependencies:
4959
- edw_paragraphs_carousel/carousel
50-
- drupal/once
60+
- core/once
5161

modules/edw_paragraphs/modules/edw_paragraphs_carousel/components/slider/slider.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
const arrows = JSON.parse(carousel.getAttribute('data-arrows'));
1212
const infinite = JSON.parse(carousel.getAttribute('data-infinite'));
1313
const fade = JSON.parse(carousel.getAttribute('data-fade'));
14+
const autoplay = JSON.parse(carousel.getAttribute('data-autoplay'));
15+
const autoplaySpeed = JSON.parse(carousel.getAttribute('data-autoplay-speed'));
1416

1517
$('.slider').slick({
1618
dots: dots,
19+
autoplay: autoplay,
20+
autoplaySpeed: parseInt(autoplaySpeed, 10),
1721
infinite: infinite,
1822
fade: fade,
19-
arrows: arrows,
23+
arrows: arrows
2024
});
2125
});
2226
}

modules/edw_paragraphs/modules/edw_paragraphs_carousel/components/slider/slider.twig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
{% set dots = dots ? 'true' : 'false' %}
2121
{% endif %}
2222

23+
{% if autoplay is not defined %}
24+
{% set autoplay = 'false' %}
25+
{% else %}
26+
{% set autoplay = autoplay ? 'true' : 'false' %}
27+
{% endif %}
28+
29+
{% if autoplaySpeed is not defined %}
30+
{% set autoplaySpeed = 2000 %}
31+
{% endif %}
32+
2333
{% if arrows is not defined %}
2434
{% set arrows = 'true' %}
2535
{% else %}
@@ -43,6 +53,8 @@
4353
{% set slider_attributes = slider_attributes.setAttribute('data-infinite', infinite) %}
4454
{% set slider_attributes = slider_attributes.setAttribute('data-arrows', arrows) %}
4555
{% set slider_attributes = slider_attributes.setAttribute('data-fade', fade) %}
56+
{% set slider_attributes = slider_attributes.setAttribute('data-autoplay', autoplay) %}
57+
{% set slider_attributes = slider_attributes.setAttribute('data-autoplay-speed', autoplaySpeed) %}
4658

4759
<div class="grid-container">
4860
<div{{ slider_attributes.addClass(slider_classes) }}>

0 commit comments

Comments
 (0)