Skip to content

[Bug]: Carousel onCycleTo method does not get called #639

@trymeouteh

Description

@trymeouteh

Before submitting...

Context

The onCycleTo() method does not get called when I interact with a carousel.

Current Behavior

The onCycleTo() method never gets called

Expected behavior

The onCycleTo() method gets called when the carousel item is moved.

Possible Solutions or Causes

Perhaps this method is depricated?

Steps to reproduce

  1. npm i @materializecss/materialize
  2. Copy this code into a file called test.html
<link rel="stylesheet" href="node_modules/@materializecss/materialize/dist/css/materialize.min.css" />

<style>
	.carousel-item div {
		height: 100%;

		border: 5px solid black;

		background-color: red;

		font-size: 48;
		text-align: center;
	}
</style>

<div class="carousel carousel-slider">
	<div class="carousel-item active">
		<div>1</div>
	</div>
	<div class="carousel-item active">
		<div>2</div>
	</div>
	<div class="carousel-item active">
		<div>3</div>
	</div>
	<div class="carousel-item active">
		<div>4</div>
	</div>
</div>

<script src="node_modules/@materializecss/materialize/dist/js/materialize.min.js"></script>

<script>
	const myCarousel = M.Carousel.init(document.querySelector('.carousel'), {
		fullWidth: true,
		onCycleTo: function () {
			console.log('Hello World');
		},
	});
</script>

Your Environment

  • Version used: 2.2.2
  • Browser Name and version: Firefox 143
  • Operating System and version (desktop or mobile): Linux Mint 22
  • Additional information you want to tell us: Installed Materialize using npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions