jQueryによるウィンドウ内を、左右にスクロールするパネルのスクリプトです。
横幅1000pxのパネルを横に5枚並べて、リンクをクリックすることで目的のパネルに移動するスクリプトです。
アニメーションのイージングには「jquery.easing.1.3.js」を利用しています。
サンプルはこちら
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style.css" rel="stylesheet" type="text/css" media="all" />
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="jquery.easing.1.3.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("a.panel-01").click(function() {scrollGeneral(0)});
$("a.panel-02").click(function() {scrollGeneral(1000)});
$("a.panel-03").click(function() {scrollGeneral(2000)});
$("a.panel-04").click(function() {scrollGeneral(3000)});
$("a.panel-05").click(function() {scrollGeneral(4000)});
})
function scrollGeneral(pos) {
$("div#container").animate({scrollLeft: pos}, {duration: 750, easing: "easeOutQuint"});
return false;
}
</script>
<title>scroll-panel</title>
</head>
<body>
<!-- navi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="navi">
<ul>
<li><a href="javascript:;" class="panel-01">01</a></li>
<li><a href="javascript:;" class="panel-02">02</a></li>
<li><a href="javascript:;" class="panel-03">03</a></li>
<li><a href="javascript:;" class="panel-04">04</a></li>
<li><a href="javascript:;" class="panel-05">05</a></li>
</ul>
</div><!-- navi -->
<div id="container">
<div id="general">
<!-- panel-01 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="panel-01" class="inner">
<p>panel-01</p>
</div><!-- panel-01 -->
<!-- panel-02 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="panel-02" class="inner">
<p>panel-02</p>
</div><!-- panel-02 -->
<!-- panel-03 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="panel-03" class="inner">
<p>panel-03</p>
</div><!-- panel-03 -->
<!-- panel-04 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="panel-04" class="inner">
<p>panel-04</p>
</div><!-- panel-04 -->
<!-- panel-05 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="panel-05" class="inner">
<p>panel-05</p>
</div><!-- panel-05 -->
</div><!-- general -->
</div><!-- container -->
</body>
</html> |
style.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
| @charset "utf-8";
/* text -------------------------------------------------------------------------------- */
* {
margin: 0px;
padding: 0px;
}
html,
body {
height: 100%;
}
html {
overflow: hidden;
}
/* navi -------------------------------------------------------------------------------- */
div#navi {
position: absolute;
}
/* container -------------------------------------------------------------------------------- */
div#container {
overflow: hidden;
width: 100%;
height: 100%;
}
/* general -------------------------------------------------------------------------------- */
div#general {
width: 6000px;
height: 100%;
}
div#general div.inner {
float: left;
width: 1000px;
height: 800px;
}
div#general div.inner p {
font-family: Helvetica, Arial, sans-serif;
font-size: 60px;
color: #d9d9d9;
padding: 30px 60px;
}
/* panels -------------------------------------------------------------------------------- */
div#panel-01 {
background: #f8f8f8;
}
div#panel-02 {
background: #ffffff;
}
div#panel-03 {
background: #f8f8f8;
}
div#panel-04 {
background: #ffffff;
}
div#panel-05 {
background: #f8f8f8;
} |
コメントはまだありません。
この投稿へのコメントの RSS フィード。
TrackBack URL
|