How does it work?
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.
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.
The jQuery code for this particular demo looks like this:
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:
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:
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 |