ngx-slick-carousel: a carousel that loops infinitely and adjusts responsively

I have implemented ngx-slick-carousel to showcase YouTube videos in my project. However, I am facing two main issues. Firstly, the carousel is not infinite, and when the last video is reached, there appears to be white spaces before it loops back to the first slide. I would like the carousel to seamlessly display the first slide next to the last one without having to animate back to the beginning.

Secondly, I have tried incorporating responsive design by adding code to my TypeScript file. Unfortunately, it seems that the YouTube video is not responding to this setup. I also attempted to utilize Bootstrap grid with no success. Any advice on resolving these challenges?

HTML file

<div class="row">
  <div class="col-lg-9">
    <div class="slick-wrapper">
      <ngx-slick-carousel class="carousel" #slickModal="slick-carousel" [config] = "slideConfig" (init)="slickInit($event)" (breakpoint)="breakpoint($event)">
        <div ngxSlickItem *ngFor="let slide of slides" class="slide">
          <div class="col-md-4">
            <youtube-player 
              videoId= {{slide.videoId}}
              suggestedQuality="default" 
              [height]="" 
              [width]="" 
              [startSeconds]="0"
              [endSeconds]="">
            </youtube-player>
          </div>  
        </div>
      </ngx-slick-carousel>
    </div>  
  </div>
</div>

TS file

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-videos',
  templateUrl: './videos.component.html',
  styleUrls: ['./videos.component.css']
})
export class VideosComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
    const tag = document.createElement('script');

    tag.src = "https://www.youtube.com/iframe_api";
    document.body.appendChild(tag);
  }

  slides = [
    {videoId: "rf8vM_X1g9U"},
    {videoId: "3xq7z7WBOGU"},
    {videoId: "9PBeqHEopLs"},
    {videoId: "1jeHyrRskdk"},
    {videoId: "KauOtgNuzQQ"}
  ];

  slideConfig = {
    "slidesToShow": 3, 
    "slidesToScroll": 1, 
    "autoplay": true, 
    "autoplaySpeed": 3000,
    "infinite": true,
    "responsive": [
      {
        breakpoint: 1024,
        settings: {
          slidesToShow: 3,
          slidesToScroll: 1,
        }
      },
      {
        breakpoint: 600,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 1
        }
      },
      {
        breakpoint: 480,
        settings: {
          slidesToShow: 1,
          slidesToScroll: 1
        }
      }
    ]
  };

  slickInit(e: any) {
    console.log('slick initialized');
  }

  breakpoint(e: any) {
    console.log('breakpoint');
  }

}

I only have this in my css

.slick-prev:before, .slick-next:before {
  color: black!important;
}

I'm using youTube-player Module to display the youTube videos and using the *ngFor to get the videos ID

Answer №1

After opting for a different carousel, the code can be found in this related thread

It appears that the ongoing loop problem might be a glitch; there's a relevant discussion about it on GitHub

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Could Angular2's Http Get method exclusively handle Json data?

mma-api.service.ts getAthletes() { return this.http.get('http://mma-data-api.mma.com/api/v3/athletes') .map(res => res.json()); } athlete.component.ts data: string; constructor(private mmaApiService: MmaApiService) ...

TS will not display an error when the payload is of type Partial

Why doesn't TypeScript throw an error when making the payload Partial? It seems to only check the first value but not the second one. type UserState = { user: User | null; loading: boolean; error: Error | null } type UserAction = { type: type ...

Retrieving and showing information from a database (Using Javascript Ajax)

I'm in need of assistance with a project for my course and would appreciate any guidance or help that can be offered. My task involves creating a simple JavaScript XML Http Request to display basic information (specifically the country_name & country_ ...

Generate PDF Files Using Ajax

Currently, I am utilizing FPDF to generate my report. $pdf = new Report('P','mm','A4', $_POST); $pdf->AddPage(); $pdf->Output('file.pdf','I'); Furthermore, I am employing ajax to send a request to t ...

Math operations limited by boundaries: adding and subtracting

What is the proper way to implement this logic in JavaScript: Row-=21; if (Row < 1) { Row = 1; } ...

When clearInterval is used to stop a setInterval, it will not automatically restart if reset with setInterval

I am facing an issue with a countdown timer that I have created using setInterval in JavaScript. The timer is supposed to countdown from one minute at one second intervals. However, when I click the "start" button, it starts the countdown but if I click an ...

How can I restrict the number of input data to 10 on a single page in a TodoList application?

As a newcomer to web development, I recently built a todoList app. It's functioning flawlessly and allows me to add multiple lists to my webpage with ease. The technologies used are React js and Bootstrap. However, I now wish to implement a limitati ...

Locating the Active Object's Coordinates in fabric.js

When using fabric js, I have successfully drawn various shapes like circles and rectangles. However, I encountered an issue while trying to obtain the coordinates of the rectangle using the fabric.rect() method. canvas.getActiveObject().get('points& ...

Ways to determine the types of props received by a function when the arguments vary for each scenario?

I have a specialized component that handles the majority of tasks for a specific operation. This component needs to invoke the onSubmit function received through props, depending on the type of the calling component. Below is an example code snippet show ...

Using ${} syntax to implement dynamic logic when constructing a string in Express.js

I need to iterate through an object and display values for each one while creating a string. Any suggestions on how to achieve something like this: const body = ` <h1>Values</h1> ${ for (value in values) { return `<h2>Ind ...

Displaying the JSON retrieved from the backend on the user's machine upon the user's initial request

My goal is to design an input field that provides suggestions to users based on the first letter they enter. For instance, if a user enters "A", I want all country names starting with "A" to be displayed as suggestions. Instead of querying the backend re ...

displaying outcomes as 'Indefinite' rather than the anticipated result in the input field

I need to automatically populate values into 4 text fields based on the input value entered by the user. When the user exits the input field, a function called getcredentials() is triggered. This function, in turn, executes Python code that retrieves the r ...

I am unsure about how to properly implement the reduce function

I am struggling with implementing the reduce function in my code. I have data output from a map function that consists of two documents. For example, one document contains: key "_id":"AD" "values" { "numtweets" : 1, "hastags" : ...

Is there a way to bring to life the addClass() and removeClass() jQuery functions through animation?

I am currently developing a website and I want to be able to toggle the visibility of sections by using the ".hidden" bootstrap class within click events. Here is the basic code snippet: $('selector').click(function(){ $('*part-to-hi ...

Discovering the position of elements in relation to their (grand^N)parent

Among my possessions are elements A and B. B has the ability to exist as a direct child of A, or there may be anywhere from 0 to N elements separating them. It is imperative that I determine how B is situated in relation to A, specifically noting the dist ...

Conceal the element at all times

I'm facing a challenge with a paragraph element that is dynamically filled with content using Javascript. I need to hide the element whenever it doesn't have any text within it. However, I want to avoid using setTimeout or setInterval for this ta ...

Ways to monitor and measure clicks effectively

Within my website, I have a table element with one column and numerous rows. Each row serves as a hyperlink to an external shared drive. <tr><td ><a href="file://xxx">Staff1</a></td></tr> <tr ><td ><a h ...

finding the initial element within an object using lodash in javascript

Recently, I came across some data in the form of an array of objects. For instance, let me share a sample dataset with you: "data": [ { "name": "name", "mockupImages": "http://test.com/image1.png,http://test.com/image2.png" }] ========================== ...

What steps are needed to install Angular Universal on a Windows server?

I am facing difficulties when trying to deploy (publish) my website as Angular Universal and have tried almost everything. Running npm run dev:ssr locally works perfectly fine, and I am able to see the source code of the pages including dynamic content. ...

Eliminate the loading spinner from the tab on Google Chrome

Recently, I've been working on a project to create a website and have been searching for some innovative ideas. One interesting discovery I made was . What caught my eye was the unique feature where clicking on any tab did not result in the typical sp ...