chohj06ms commited on
Commit
3e8a03d
โ€ข
1 Parent(s): b535c41

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +7 -2
script.js CHANGED
@@ -1,4 +1,4 @@
1
- let currentIndex = 0;
2
  let startTouchPosition = 0;
3
  let endTouchPosition = 0;
4
 
@@ -6,11 +6,16 @@ const slider = document.querySelector('.slider');
6
  const totalSlides = slider.children.length;
7
 
8
  function moveToSlide(n) {
9
- let newSlidePosition = (n * -100) / totalSlides;
10
  slider.style.transform = `translateX(${newSlidePosition}%)`;
11
  currentIndex = n;
12
  }
13
 
 
 
 
 
 
14
  // ํ‚ค๋ณด๋“œ ์ด๋ฒคํŠธ
15
  document.addEventListener('keydown', (e) => {
16
  if (e.key === 'ArrowLeft') {
 
1
+ let currentIndex = 1; // ๋‘ ๋ฒˆ์งธ ์นด๋“œ์—์„œ ์‹œ์ž‘ํ•˜๋„๋ก ์ธ๋ฑ์Šค ๋ณ€๊ฒฝ
2
  let startTouchPosition = 0;
3
  let endTouchPosition = 0;
4
 
 
6
  const totalSlides = slider.children.length;
7
 
8
  function moveToSlide(n) {
9
+ let newSlidePosition = ((n - 1) * -100) / (totalSlides - 1);
10
  slider.style.transform = `translateX(${newSlidePosition}%)`;
11
  currentIndex = n;
12
  }
13
 
14
+ // ํŽ˜์ด์ง€ ๋กœ๋“œ ์‹œ ๋‘ ๋ฒˆ์งธ ์Šฌ๋ผ์ด๋“œ๋กœ ์ด๋™
15
+ document.addEventListener('DOMContentLoaded', () => {
16
+ moveToSlide(currentIndex); // ์ดˆ๊ธฐ ์œ„์น˜ ์„ค์ •
17
+ });
18
+
19
  // ํ‚ค๋ณด๋“œ ์ด๋ฒคํŠธ
20
  document.addEventListener('keydown', (e) => {
21
  if (e.key === 'ArrowLeft') {