Breakpoints doesn't work

Created on 29 April 2025, 17 days ago

Problem/Motivation

I've tried many settings, but I can't get things to work. I want a simple multiple slider (with 4 perPage, and 1 perPage on mobile for example), but when breakpoint seems to be activated, the slider doesn't respond anymore (drag, pagination... they do nothing).

ul.splide__list doesn't have any inline CSS tranform property (like in working sliders, translateX(-....px)).

Steps to reproduce

My config looks like this:

group: main
skin: default
breakpoint: 1
optimized: false
options:
  settings:
    type: slide
    mediaQuery: max
    rewind: true
    rewindByDrag: false
    speed: 400
    rewindSpeed: 0
    waitForTransition: false
    width: '0'
    height: '0'
    fixedWidth: '0'
    fixedHeight: '0'
    heightRatio: '0'
    autoWidth: false
    autoHeight: false
    perPage: 4
    perMove: 1
    clones: 0
    cloneStatus: false
    start: 0
    focus: '0'
    gap: '0'
    padding: ''
    easing: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)'
    arrows: 'false'
    arrowPath: ''
    pagination: 'true'
    paginationDirection: ltr
    paginationKeyboard: true
    omitEnd: false
    autoplay: false
    interval: 5000
    pauseOnHover: true
    pauseOnFocus: true
    progress: false
    resetProgress: true
    keyboard: 'true'
    drag: 'true'
    snap: false
    noDrag: ''
    dragMinThreshold: 10
    flickVelocityThreshold: 0.6
    flickPower: 600
    flickMaxPages: 1
    direction: ltr
    cover: false
    slideFocus: false
    focusableNodes: 'a, button, textarea, input, select, iframe'
    isNavigation: false
    trimSpace: 'true'
    live: true
    updateOnMove: false
    classes: ''
    i18n: ''
    autoScroll: ''
    intersection: ''
    down: false
    downTarget: ''
    downOffset: 0
    easingOverride: easeInOutCubic
    randomize: false
    wheel: false
    releaseWheel: false
    wheelMinThreshold: 0
    wheelSleep: 0
    animation: ''
  breakpoints:
    -
      breakpoint: 540
      unsplide: false
      settings:
        rewind: false
        speed: 400
        width: '0'
        height: '0'
        fixedWidth: '0'
        fixedHeight: '0'
        heightRatio: '0'
        perPage: 1
        perMove: 1
        clones: 0
        focus: center
        gap: '0'
        padding: ''
        easing: 'cubic-bezier(.42,.65,.27,.99)'
        arrows: 'false'
        pagination: 'false'
        drag: 'true'
        snap: false
        direction: ltr

Am I missing something?

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France nicodh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nicodh
  • 🇮🇩Indonesia gausarts

    Thank you.

    pagination should be true, your Breakpoint says:
    pagination: 'false'

    drag looks correct:
    drag: 'true'
    Not sure, why it failed, but possible solutions/debugs:

    • Verify the library version is correct, see project home.
    • Disable Override Main Optionset option at your formatter or Views style
    • Press CTRL/CMD + SHIFT + M to access mobile version if using laptop/desktop
    • Ensure you have at least 5 slides, if perPage is 4, etc.
    • Install Splide X, and verify the samples work, or not.

    Let me know?

  • 🇫🇷France nicodh

    Thanks for your advices.

    After more digging, I found the problem: on the same page, I render another splide, programmatically, with a different optionset (called fullscreen, with fade type and no breakpoint), to show a fullscreen slider of medias in background of page's heading. This splide shows only one item perPage, but has only one item. If I bypass splide for this case (and render directly the media entity), everything works fine.

    Any idea how this behavior happens? Is it an issue with splide library or with this module overrides?

    Is there a way, programmatically, to do something like: if items count is less or equal than perPage => destroy / "unslick"?

  • 🇮🇩Indonesia gausarts

    > programmatically

    • You might mess up reserved selectors. See Splide UI for different types, reserved vs custom. Hence splide--default should not be used for custom works.
    • Your JS is not using custom unique selector. Similar to point 1, only at JS.

    To prove/ validate such a conflict, put each at separate pages.
    To have custom works play nice with core/default, see/clone the provided sample JS initiator/loader.

  • 🇫🇷France nicodh

    By programmatically I mean with splide.manager service, not directly in JS.

    What's strange is that on the same page, I try with one "complex" paragraph, resulting in programmatically computed splide (in preprocesses, with SplideManager) and one "simple" entity reference field with splide formatter, and both don't work (only in breakpoints' conditions, the initial desktop options work well) if I render my header splide with only 1 item. I try to render it with 2 items, and all splides work.

    My header splide is rendered like this (simplified):

            $splideBuild = [
              '#settings' => [
                'optionset' => 'fullscreen',
              ],
              '#options' => [],
              'items' => [],
            ];
    
              foreach ($medias as $delta => $media) {
                $splideBuild['items'][] = [
                  '#delta' => $delta,
                  '#attributes' => [
                    'class' => ['slide--delta--' . $delta],
                  ],
                  'slide' => $viewBuilderMedia->view($media, $style),
                ];
              }
    
              $variables['page_banner_medias'] = \Drupal::service('splide.manager')->build($splideBuild);
    

    In my tests I have 2 optionsets:

    • Multiple: slide, with 4 per page with breakpoints to have only 1 on mobile
    • Fullscreen: fade, with 1 per page always (I try no breakpoint at all, or 1 breakpoint with the same values)

    And my use cases:

    • 1 splide with Multiple optionset, from entity reference formatter: OK
    • 1 splide with Multiple optionset, with custom build with splide.manager: OK
    • Both entity reference formatter and custom build on the same page: OK
    • Both with more and less items than perPage value: OK
    • Both and 1 splide with Fullscreen optionset and 2 items in it: OK
    • With Fullscreen and only one item in it: Not OK

    To fix this, instead of:

              $variables['page_banner_medias'] = \Drupal::service('splide.manager')->build($splideBuild);
    

    I do:

              if (count($splideBuild['items']) > 1) {
                $variables['page_banner_medias'] = \Drupal::service('splide.manager')->build($splideBuild);
              } else {
                $variables['page_banner_medias'] = $splideBuild['items'][0]['slide'];
              }
    

    But it needs more lines everywhere I build a splide, plus some specific css in frontend.

    So, I really think that something is wrong somewhere, in my side or in module or library...

  • 🇮🇩Indonesia gausarts

    > With Fullscreen and only one item in it: Not OK

    What is it "Not OK"?

    We need to understand OK meaning here :)

    To validate OK vs Not OK, try testing with with Splide field formatter/Views style.
    If it is OK, then the problem is yours.
    If not OK, then both are actually OK.

    Why? Technically if 1 item, Splide is being destroyed, no more sliding behaviors.
    Thus its "brokenness" or being destroyed or "Not OK" is actually OK :)

    One obvious missing line is #settings property in the individual item loop like here:
    https://git.drupalcode.org/project/splide/-/blob/2.0.x/splide.api.php?re...

    There a sample of Fullscreen, IIRC. Try installing Splide X, and see if OK with your designated contents.

  • 🇫🇷France nicodh

    I already handle the behavior "if 1 item, Splide is being destroyed", I'm OK with that.

    What I mean with "Not OK" is that if my Splide has only 1 item, I don't know why but on the same page are broken: they are not destroyed but widths, active slides... are not good, even if I refresh or interact with splide directly in JS in browser console.

    After more digging, I figured out that:

    • What I've called "Not OK" is not depending on standard field formatter or view or custom rendering with Splide manager (which I have tried with #settings property on each item)
    • I try with 3 standard sliders, rendered by simple field formatters, and whenever I have one slider with only one item, the
    • It's happening

    So, it's probably on my side, but I can't point out which misconfiguration I do.

  • 🇮🇩Indonesia gausarts

    My recommendations:

    • Remove conditions (IF ELSE) in #5 above. Use Splide rendering except that now knowing and understanding that 1 item is destroyed (no more drags, pagination, etc.) as OP described.
    • Install Splide X, clone and limit the amount of contents to 1 to replicate your problematic situation, and others to unlimited, etc. And see if any difference. You can judge correctly given a comparison aka well-informed which one works and not.

    Please share your findings and solutions to benefit others.

Production build 0.71.5 2024