Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

[JS] 롤링 갤러리 구현

2011-09-23 by 편리

jQuery를 이용해서 롤링 갤러리를 한번 만들어 봤다. 이미지가 3개로 고정되어 있어서 가능했지 그렇지 않았으면
내 실력으로 구현을 할 수가 있었을지 자신은 없다. 갤러리는 아래 이미지와 같다. 세로 1~3번을 클릭하면 그에 따라
이미지 보여지고 클릭했던 세로 바는 위치 이동 후 사라지는 것인데.. 쉽게 생각했다 된통 당했다. 실력이 없어서..

<script type=”text/javascript”>
var current_idx = 0;
var old_idx = -1;
$(function() {
$(‘div#intro_indicator1’).addClass(“indicator_right”);
var ImageRotate = setInterval(“IntroImageRotate()”, 3500);
$(‘div.indicator_left’).click(function() {
current_idx =  $(‘div.indicator_left’).index($(this));
old_idx = current_idx – 1;
IntroImageRotate();
});
$(‘div#MainImgArea’).hover(
function() {
clearInterval(ImageRotate);
},
function() {
ImageRotate = setInterval(“IntroImageRotate()”, 3500);
}
);
});
function IntroImageRotate()
{
current_idx = (old_idx + 1) % 3;
if(!$(‘div.indicator_left:eq(‘ + current_idx + ‘)’).is(“.indicator_right”)) {
if(current_idx == 1) {
$(‘div#intro_indicator1’).addClass(“indicator_right”).css(“left”, “571px”).show();
$(‘div#intro_indicator2’).addClass(“indicator_right”).css(“left”, “541px”).hide();
$(‘div#intro_indicator3’).css(“left”, “0px”).show();
} else if(current_idx == 2) {
$(‘div#intro_indicator1’).addClass(“indicator_right”).css(“left”, “571px”).show();
$(‘div#intro_indicator2’).addClass(“indicator_right”).css(“left”, “541px”).show();
$(‘div#intro_indicator3’).css(“left”, “0px”).hide();
} else {
$(‘div#intro_indicator1’).addClass(“indicator_right”).css(“left”, “571px”).hide();
$(‘div#intro_indicator2’).css(“left”, “30px”).show();
$(‘div#intro_indicator3’).css(“left”, “0px”).show();
}
} else {
if(current_idx == 1) {
$(‘div#intro_indicator1’).css(“left”, “571px”).show();
$(‘div#intro_indicator2’).css(“left”, “541px”).hide();
$(‘div#intro_indicator3’).removeClass(“indicator_right”).css(“left”, “0px”).show();
} else if(current_idx == 2) {
$(‘div#intro_indicator1’).css(“left”, “571px”).show();
$(‘div#intro_indicator2’).css(“left”, “541px”).show();
$(‘div#intro_indicator3’).removeClass(“indicator_right”).css(“left”, “0px”).hide();
} else {
$(‘div#intro_indicator1’).css(“left”, “571px”).hide();
$(‘div#intro_indicator2’).removeClass(“indicator_right”).css(“left”, “30px”).show();
$(‘div#intro_indicator3’).removeClass(“indicator_right”).css(“left”, “0px”).show();
}
}
$(‘div.intro_image’).hide();
$(‘div.intro_image:eq(‘ + current_idx + ‘)’).show();
old_idx = current_idx;
}
</script>

3.5초마다 이미지 롤링되고 마우스 오버 시에는 롤링이 멈추는 구조이다. jQuery를 접한 지 얼마되지 않아 이런
방법으로 밖에 구현을 못하지만 나중에 실력이 좀 더 쌓이면 심플하면서도 간결하게 구현할 수 있지 않을까 생각만
하고 있다. 그 때까지 노력을 많이 해야할텐데.. 그게 과연 쉬울지 모르겠다. 이걸 함수로 만들면 참 좋을텐데.. ^^;
 

Post navigation

Previous Post:

[JS] Frameset 사용 페이지에서 URL 변경하기

Next Post:

치밀함이 무섭다고?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅
  • 우분투 시스템 터미널쉘 zsh 로 변경

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes