본문 바로가기
반응형

홈페이지를 보게되면 화면을 스크롤 할 때 배경의 이미지가 스크롤에 비해 더 조금씩 움직임으로써 역동적으로 보이게 하는 기술을 볼 수 있습니다.
이것을 Parallax(시차)라는 이름으로 많이 사용되고 있는데.. jQuery의 플러그인으로 구현된 것이 있어 소개합니다.

**홈페이지 : ** [https://github.com/pederan/Parallax-ImageScroll](https://github.com/pederan/Parallax-ImageScroll)
**DEMO : ** [http://codepen.io/pederan/full/Hheuy](http://codepen.io/pederan/full/Hheuy)
**라이선스 : ** MIT

Install

bower로 설치할 경우

bower install Parallax-ImageScroll

npm으로 설치할 경우

npm install parallax-imagescroll

일반 사용법

HTML

<div class="img-holder" data-image="anImage.jpg"></div>
<section><p>Content that "slides" on top of the images</p></section>
<div class="img-holder" data-image="anotherImage.jpg">[optional content to be displayed on top of the images]</div>

javascript

jQuery와 jquery.imageScroll.js를 먼저 임포트한 후 설정값을 지정해 줍니다.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../jquery.imageScroll.js"></script>
<script>
      $('.img-holder').imageScroll({
//            image: null,
//            imageAttribute: 'image',
//            container: $('body'),
//            speed: 0.2,
//            coverRatio: 0.75,
//            holderClass: 'imageHolder',
//            holderMinHeight: 200,
//            extraHeight: 0,
//            mediaWidth: 1600,
//            mediaHeight: 900,
//            parallax: true,
//            touch: false
      });
  </script>

나만모르는 이야기

여행, 맛집,IT, 리뷰에 대한 이야기를 공유하는 블로그 .