swiper icon indicating copy to clipboard operation
swiper copied to clipboard

ControllerOptions control does not work when passed an array of Swiper[]

Open smileypop opened this issue 3 years ago • 2 comments

Check that this is really a bug

  • [X] I confirm

Reproduction link

https://github.com/smileypop/wordy

Bug description

I have 3 swipers with two-way controls setup.

  • Swiper 1 controls Swiper 2
  • Swiper 2 controls Swiper 1
  • Swiper 3 controls an array [Swiper 1, Swiper 2]

ControllerOptions allows control to be defined as either a single instance of Swiper or an array of Swipers.

However, during actual usage the controller only functions when assigning a single instance, not an array.

Here is the implementation:

export interface ControllerOptions {
  /**
   * Pass here another Swiper instance or array with Swiper instances that should be controlled
   * by this Swiper
   */
  control?: Swiper | Swiper[];

  /**
   * Set to `true` and controlling will be in inverse direction
   *
   * @default false
   */
  inverse?: boolean;

  /**
   * Defines a way how to control another slider: slide by slide
   * (with respect to other slider's grid) or depending on all slides/container
   * (depending on total slider percentage).
   *
   * @default 'slide'
   */
  by?: 'slide' | 'container';
}

Expected Behavior

  • Swiper 1 controls Swiper 2 (OK)
  • Swiper 2 controls Swiper 1 (OK)
  • Swiper 3 controls an array [Swiper 1, Swiper 2] (OK)

Actual Behavior

  • Swiper 1 controls Swiper 2 (OK)
  • Swiper 2 controls Swiper 1 (OK)
  • Swiper 3 controls an array [Swiper 1, Swiper 2] (Not OK)

Swiper version

8.0.5

Platform/Target and Browser Versions

macOS 12.1 Chrome 97.0.4692.99

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the docs.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • [X] Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • [ ] I'm willing to open a PR

smileypop avatar Feb 10 '22 23:02 smileypop

The same happens for Vue

thplat avatar Mar 07 '22 22:03 thplat

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 04:09 stale[bot]

New Swiper v9 doesn't have Svelte components anymore, it is recommended to use new Swiper Web Components instead.

nolimits4web avatar Feb 01 '23 10:02 nolimits4web