sliding

2012. 11. 15. 20:31

How does it work?

링크:  
http://www.smoothdivscroll.com/#quickdemo

The basic principle behind Smooth Div Scroll is simple: let one div (scrollableArea) scroll inside another div (scrollWrapper). Two hotspots are used to trigger the actual scrolling (scrollingHotSpotLeft andscrollingHotSpotRight). You can also let the user scroll using touch, the mouse wheel or just let the scroller auto scroll. The scrollWrapper determines how much of the scrollableArea that should be visible - everything outside the scrollWrapper is hidden from view.

Illustration showing the different elements of Smooth Div Scroll

Quick demo

Here's a quick demo of Smooth Div Scroll in action. I've set the options so the user can scroll using the hotspots or the mouse wheel . I've also told the scroller to start auto scrolling as soon as the page loads and stop auto scrolling as soon as the user interacts with the scoller. Touch scrolling is not enabled for this particular demo - check out the touch demo if you want to try touch scrolling.

RiverTrainLeafDogFieldGnomePencilsGolf

The jQuery code for this particular demo looks like this:


<script type="text/javascript">
	$(document).ready(function () {
		$("#makeMeScrollable").smoothDivScroll({
			mousewheelScrolling: "allDirections",
			manualContinuousScrolling: true,
			autoScrollingMode: "onStart"
		});
	});
</script>

In this particular demo I've set some options that override the default options:

  • mousewheelScrolling: "allDirections" - The user can scroll using the mouse wheel, both horizontally and vertically (not all mice have a vertical scrolling function though)
  • manualContinuousScrolling: true - The scroller becomes endless in both directions when the user scrolls manually (using the hotspots or the mousewheel).
  • autoScrollingMode: "onStart" - The scroller will start auto scrolling as soon as the page has loaded and stop auto scrolling as soon as the user interacts with the scoller.

I've used only a few of all the available options. You'll find all the options described here.) In the demo above the HTML-code looks like this:


	<div id="makeMeScrollable">
		<img src="images/demo/field.jpg" alt="Field" id="field" />
		<img src="images/demo/gnome.jpg" alt="Gnome" id="gnome" />
		<img src="images/demo/pencils.jpg" alt="Pencils" id="pencils" />
		<img src="images/demo/golf.jpg" alt="Golf" id="golf" />
		<img src="images/demo/river.jpg" alt="River" id="river" />
		<img src="images/demo/train.jpg" alt="Train" id="train" />
		<img src="images/demo/leaf.jpg" alt="Leaf" id="leaf" />
		<img src="images/demo/dog.jpg" alt="Dog" id="dog" />
	</div>

As you can see there is a surrounding div with the id makeMeScrollable. This is the element that I turn into a Smooth Div Scroll. Inside this div you can put any content - not just images.

Please note that you may have to give the elements that you put inside the scrollable area some styling to make sure that they are positioned like you want them. Here's a good template to start with:


#makeMeScrollable div.scrollableArea *
{
	position: relative;
	display: block
	float: left;
	margin: 0;
	padding: 0;
	/* If you don't want the images in the scroller to be selectable, try the following
		block of code. It's just a nice feature that prevent the images from
		accidentally becoming selected/inverted when the user interacts with the scroller. */
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-o-user-select: none;
	user-select: none;
}

In this example there's no space between the elements inside the scrollable area. If you want a space between them, use padding and not margin since margin tends to generate errors in Internet Explorer.


'J-Query' 카테고리의 다른 글

jquery 움직이는 스크롤 사이드바  (0) 2012.11.15
jQuery 라이브러리 사용 방법  (1) 2012.11.15
컬럼 추가 삭제  (0) 2012.09.10
jQuey 1.8 이 정식 릴리즈 되었습니다.  (0) 2012.08.24
jQuery.slide()  (0) 2012.07.10
Posted by 사라링
BLOG main image
.. by 사라링

카테고리

사라링님의 노트 (301)
JSP (31)
J-Query (41)
JAVA (24)
VM-WARE (0)
디자인패턴 (1)
스크랩 (0)
스트러츠 (3)
안드로이드 (11)
오라클 (45)
우분투-오라클 (1)
이클립스메뉴얼 (6)
스프링3.0 (23)
자바스크립트 (10)
HTML5.0 (17)
정보처리기사 (1)
기타(컴퓨터 관련) (1)
문제점 해결 (3)
프로젝트 (2)
AJAX (4)
하이버네이트 (3)
트러스트폼 (11)
Jeus (2)
재무관리(회계) (5)
정규식 (5)
아이바티스 (8)
취미 (2)
소프트웨어 보안 관련모음 (0)
정보보안기사 (6)
C언어 베이직 및 프로그램 (3)
보안 관련 용어 정리 (2)
넥사크로 (6)
Total :
Today : Yesterday :