{"size": 1179, "ext": "js", "max_stars_repo_path": "src/components/finish/slideList/SlideList.js", "max_stars_repo_name": "JaeYeopHan/customize_your_travel_prj", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/finish/slideList/SlideList.js", "max_issues_repo_name": "JaeYeopHan/customize_your_travel_prj", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/finish/slideList/SlideList.js", "max_forks_repo_name": "JaeYeopHan/customize_your_travel_prj", "max_forks_repo_forks_event_min_datetime": "2019-12-31T04:48:31.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-31T04:48:31.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 21.0535714286, "max_line_length": 88, "alphanum_fraction": 0.6564885496}
import PureComponent from "../../PureComponent";
import SlideListTemplate from "./SlideList.hbs";
import "./SlideList.css";

/**
 * List Component for rendering SlotList
 */
class SlideList extends PureComponent {
	/**
	 * @param {HTMLElement} root The root element for which the component will be rendered.
	 */
	constructor(root) {
		super(root);
		this._elmRoot = super.render(SlideListTemplate(), "#slide_lists");
		this.flickRoot = document.querySelector("#slide_lists");
	}

	/**
	 * @description Methods for injecting events into the component
	 * @param {appState} state State of app 
	 */
	addListener({changeSlideId, attachEvent}) {
		if (this.flickRoot.children.length === 0) {
			return;
		}
		this.flicking = new eg.Flicking(this.flickRoot, {
			bounce: [50, 50],
		});
		this.flicking.on({
			"flickEnd": ({no}) => {
				changeSlideId(no);
			},
		});
		attachEvent();
	}

	/**
	 * 
	 * @param {Object} state Event Object or appState Object
	 */
	moveTo({state}) {
		if (typeof state.slideId === "number") {
			this.flicking.moveTo(state.slideId);
		}
	}

	/**
	 * @return {HTMLElmenet}
	 */
	get subRoot() {
		return this._elmRoot;
	}
}

export default SlideList;
