• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 JavaScript, TS 게시판 캐러셀 스와이프 질문드립니다.

캐러셀 스와이프 질문드립니다.

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #46952

    서준표
    참가자
    2번쨰 3번쨰 이미지도 잡아 끌 수 있게 하려는데,
    
    
    $('.slide-box').eq(0).on('mousedown', function(e){
            시작좌표 = e.clientX; 
            누름 = true;
          });
          $('.slide-box').eq(0).on('mousemove', function(e){  
            이동좌표 = e.clientX; 
            이동 = 이동좌표 - 시작좌표  
            
            if (누름 == true) {
              $('.slide-container').css('transform', `translateX(${이동}px)`);
            }   
          });
          $('.slide-box').eq(0).on('mouseup', function(e){
            누름 = false;
            if (이동 < -100){
              $('.slide-container').css('transition', 'all 0.5s')
              $('.slide-container').css('transform', 'translateX(-100vw)');
            }
            else if (이동 > 0) {
              $('.slide-container').css('transition', 'all 0.5s')
              $('.slide-container').css('transform', 'translateX(0vw)')
            }       
            else {
              $('.slide-container').css('transition', 'all 0.5s')
              $('.slide-container').css('transform', 'translateX(0vw)');
            }
            setTimeout(() => {
              $('.slide-container').css('transition', 'none')
            },500)
          });
    
    복붙하고 eq()만 수정해줬더니 2번쨰 이미지 움직일 떄마다, 첫번째 이미지로 돌아갑니다.
    아마, 
    
    if (누름 == true) {
              $('.slide-container').css('transform', `translateX(${이동}px)`);
            }   
    
    요 부분에서 trasnslateX 값이 0이 되서 첫번쨰 이미지로 돌아가는거 같은데,
    어떻게 해결 할 수 있을까요?
    #46976

    codingapple
    키 마스터
    둘째사진을 100px 잡아끌면 
    $('.slide-container').css('transform', `translateX(100px)`); 이게 실행될 것 같은데 
    이건 첫째사진이 보이는 좌표같군요
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠