HEX
Server: Apache
System: Linux www 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64
User: root (0)
PHP: 8.2.1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals
Upload Files
File: /mnt/drbd/www/edenhouse/wp-content/plugins/essential-blocks/blocks/parallax-slider/src/slider.js
/**
 * Internal dependencies
 */
import Slide from "./slide";
import SliderControl from "./slide-control";

const Slider = ({ slides, attributes, setAttributes }) => {
	const { current, prevIcon, nextIcon, iconColor } = attributes;

	const handleSlideClick = (current) => setAttributes({ current });

	const handlePreviousClick = () => {
		const previous = current - 1;
		const updateCurrent = previous < 0 ? slides.length - 1 : previous;
		handleSlideClick(updateCurrent);
	};

	const handleNextClick = () => {
		const next = current + 1;
		const updateCurrent = next === slides.length ? 0 : next;
		handleSlideClick(updateCurrent);
	};

	const wrapperTransform = {
		transform: `translateX(-${current * (100 / slides.length)}%)`,
	};

	return (
		<div className="eb-parallax-container">
			<div className="eb-parallax-slider">
				<ul className="eb-parallax-wrapper" style={wrapperTransform}>
					{slides.map((slide, index) => (
						<Slide
							key={index}
							position={index}
							slide={slide}
							handleSlideClick={handleSlideClick}
							attributes={attributes}
						/>
					))}
				</ul>

				<div className="eb-slider__controls">
					<SliderControl
						type="previous"
						icon={prevIcon}
						handleClick={handlePreviousClick}
					/>

					<SliderControl
						type="next"
						icon={nextIcon}
						handleClick={handleNextClick}
					/>
				</div>
			</div>
		</div>
	);
};

export default Slider;