-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.html
342 lines (331 loc) · 13.5 KB
/
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>jquery.simple-scroll-follow</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css">
<link rel="stylesheet" href="sample/sample.css">
</head>
<body>
<header class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="page-title">jquery.simple-scroll-follow</h1>
<p lang="en">
jQuery plugin to move the element according to the scrolling window.
</p>
<p lang="ja">
指定した要素を画面スクロールに追従させます。
</p>
<p>
<a href="https://github.com/sutara79/jquery.simple-scroll-follow"><img src="https://img.shields.io/github/stars/sutara79/jquery.simple-scroll-follow.svg?style=social&label=Stars" alt="github repository"></a>
<a href="https://www.npmjs.com/package/jquery.simple-scroll-follow"><img src="https://img.shields.io/npm/v/jquery.simple-scroll-follow.svg" alt="npm version"></a>
</p>
</div>
</header>
<div class="container">
<div class="row main">
<nav class="col-lg-4 mb-3 toc">
<div id="js-menu-follow">
<div class="btn-group">
<button id="lang-en" class="btn btn-primary js-btn-lang" type="button" data-lang="en">English</button>
<button id="lang-ja" class="btn btn-primary js-btn-lang" type="button" data-lang="ja">日本語</button>
</div>
<h5 class="mt-2">
<span lang="en">Index</span>
<span lang="ja">目次</span>
</h5>
<div class="list-group">
<a class="list-group-item list-group-item-action" href="#basic">
<span lang="en">Basic</span>
<span lang="ja">基本</span>
</a>
<a class="list-group-item list-group-item-action" href="#attention">
<span lang="en">Attention</span>
<span lang="ja">注意点</span>
</a>
<a class="list-group-item list-group-item-action" href="#limit_elem">
<span lang="en">"limit_elem" for setting bottom limit</span>
<span lang="ja">"limit_elem"で下限を設定</span>
</a>
<a class="list-group-item list-group-item-action" href="#min_width">
<span lang="en">"min_width" for responsive design</span>
<span lang="ja">"min_width"でレスポンシブデザインに対応</span>
</a>
<a class="list-group-item list-group-item-action" href="#enabled">
<span lang="en">"enabled" for disabling this plugin by default</span>
<span lang="ja">"enabled"で追尾の有効・無効を設定する</span>
</a>
<a class="list-group-item list-group-item-action" href="#fixed-elem">
<span lang="en">Fixed element</span>
<span lang="ja">固定要素に隠れないようにする</span>
</a>
<a class="list-group-item list-group-item-action" href="#public-method">
<span lang="en">Call public method from outside</span>
<span lang="ja">パブリックメソッドを外部から実行する</span>
</a>
<a class="list-group-item list-group-item-action" href="#complex">
<span lang="en">A more complex example</span>
<span lang="ja">複雑な使用例</span>
</a>
</div>
</div>
</nav>
<article class="col-lg-8">
<section id="basic" class="card">
<h5 class="card-header">
<span lang="en">Basic</span>
<span lang="ja">基本</span>
</h5>
<div class="card-body">
<div class="btn-container">
<a class="btn btn-primary" href="sample/basic/" target="_blank">
Sample
<svg class="octicon octicon-link-external" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 10h1v3c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h3v1H1v10h10v-3zM6 2l2.25 2.25L5 7.5 6.5 9l3.25-3.25L12 8V2H6z"></path></svg>
</a>
</div>
<h6>HTML</h6>
<pre>
<aside>Element to follow</aside>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="jquery.simple-scroll-follow.min.js"></script>
</pre>
<h6>CSS</h6>
<pre>
aside {
position: <span class="red">absolute</span>;
}
</pre>
<h6>JavaScript</h6>
<pre>
$('aside').simpleScrollFollow();
</pre>
</div>
</section>
<section id="attention" class="card">
<h5 class="card-header">
<span lang="en">Attention</span>
<span lang="ja">注意点</span>
</h5>
<div class="card-body">
<ul>
<li>
<p lang="en">
<code>position: absolute</code> is required.
</p>
<p lang="ja">
追尾する要素には<code>position: absolute</code>が必須です。
</p>
</li>
<li>
<p lang="en">
It is not required, but for preventing a screen flickers on Google Chrome, the following is recommended.
</p>
<p lang="ja">
必須ではありませんが、Google Chromeで追尾要素がちらつく現象を防ぐため、下記の設定をお勧めします。
</p>
<h6>CSS</h6>
<pre>
body {
background: url(null) fixed;
}
</pre>
</li>
</ul>
</div>
</section>
<section id="limit_elem" class="card">
<h5 class="card-header">
<span lang="en">"limit_elem" for setting bottom limit.</span>
<span lang="ja">"limit_elem"で下限を設定</span>
</h5>
<div class="card-body">
<div class="btn-container">
<a class="btn btn-primary" href="sample/limit_elem/" target="_blank">
Sample
<svg class="octicon octicon-link-external" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 10h1v3c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h3v1H1v10h10v-3zM6 2l2.25 2.25L5 7.5 6.5 9l3.25-3.25L12 8V2H6z"></path></svg>
</a>
</div>
<h6>HTML</h6>
<pre>
<div>
<article> ... </article>
<aside> ... </aside>
</div>
</pre>
<h6>JavaScript</h6>
<pre>
$('aside').simpleScrollFollow({
<span class="green">limit_elem</span>: <span class="red">'article'</span>
});
</pre>
<p lang="en">
If <code>limit_elem</code> is empty, it will be set to <code>'body'</code>.
</p>
<p lang="ja">
<code>limit_elem</code>を指定しない場合は、下限はbody要素の下端となります。
</p>
</div>
</section>
<section id="min_width" class="card">
<h5 class="card-header">
<span lang="en">"min_width" for responsive design</span>
<span lang="ja">"min_width"でレスポンシブデザインに対応</span>
</h5>
<div class="card-body">
<div class="btn-container">
<a class="btn btn-primary" href="sample/min_width/" target="_blank">
Sample
<svg class="octicon octicon-link-external" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 10h1v3c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h3v1H1v10h10v-3zM6 2l2.25 2.25L5 7.5 6.5 9l3.25-3.25L12 8V2H6z"></path></svg>
</a>
</div>
<h6>CSS</h6>
<pre>
/* for PC */
@media screen and (min-width:992px) {
aside {
width: 300px;
position: absolute;
top: 0px;
left: 500px;
}
}
/* for Smart Phone */
@media screen and (max-width:991px) {
aside {
width: 600px;
position: static;
top: auto;
left: auto;
}
}
</pre>
<h6>JavaScript</h6>
<pre>
$('aside').simpleScrollFollow({
<span class="green">min_width</span>: <span class="red">992</span> // Integer. Don't add "px".
});
</pre>
</div>
</section>
<section id="enabled" class="card">
<h5 class="card-header">
<span lang="en">"enabled" for disabling this plugin by default</span>
<span lang="ja">"enabled"で追尾の有効・無効を設定する</span>
</h5>
<div class="card-body">
<div class="btn-container">
<a class="btn btn-primary" href="sample/enabled/" target="_blank">
Sample
<svg class="octicon octicon-link-external" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 10h1v3c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h3v1H1v10h10v-3zM6 2l2.25 2.25L5 7.5 6.5 9l3.25-3.25L12 8V2H6z"></path></svg>
</a>
</div>
<pre>
$('#enabled').simpleScrollFollow({
<span class="green">enabled</span>: <span class="red">true</span>
});
$('#disabled').simpleScrollFollow({
<span class="green">enabled</span>: <span class="red">false</span>
});
</pre>
</div>
</section>
<section id="fixed-elem" class="card">
<h5 class="card-header">
<span lang="en">Fixed element</span>
<span lang="ja">固定要素に隠れないようにする</span>
</h5>
<div class="card-body">
<div class="btn-container">
<a class="btn btn-primary" href="sample/fixed-elem/" target="_blank">
Sample
<svg class="octicon octicon-link-external" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 10h1v3c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h3v1H1v10h10v-3zM6 2l2.25 2.25L5 7.5 6.5 9l3.25-3.25L12 8V2H6z"></path></svg>
</a>
</div>
<p>Since: v3.1.0</p>
<p lang="en">
If you use fixed menu such as <a href="https://getbootstrap.com/docs/4.0/components/navbar/#placement" target="_blank">Bootstrap4 .navbar .fixed-top</a>, the options below will help you.
</p>
<p lang="ja">
<a href="https://getbootstrap.com/docs/4.0/components/navbar/#placement" target="_blank">Bootstrap4 .navbar .fixed-top</a>のような固定メニューに隠れないようにするため、下記のオプションを指定してください。
</p>
<pre>
$('aside').simpleScrollFollow({
<span class="green">upper_side</span>: '#menu-fixed-top',
<span class="green">lower_side</span>: '#menu-fixed-bottom'
});
</pre>
</div>
</section>
<section id="public-method" class="card">
<h5 class="card-header">
<span lang="en">Call public method from outside</span>
<span lang="ja">パブリックメソッドを外部から実行する</span>
</h5>
<div class="card-body">
<div class="btn-container">
<a class="btn btn-primary" href="sample/public-method/" target="_blank">
Sample
<svg class="octicon octicon-link-external" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 10h1v3c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h3v1H1v10h10v-3zM6 2l2.25 2.25L5 7.5 6.5 9l3.25-3.25L12 8V2H6z"></path></svg>
</a>
</div>
<p>Since: v3.0.0</p>
<p lang="en">
Set the method name to the first argument.<br>
The rest argument is for that method.
</p>
<p lang="ja">
第1引数にメソッド名を文字列で指定します。<br>
第2引数以降はそのメソッドの引数になります。
</p>
<pre>
// apply plugin firstly
$('aside').simpleScrollFollow();
$('#toggle_scroll').click(function() {
if ($(this).text() == 'click to disable scroll') {
$('aside')<span class="green">.simpleScrollFollow(<span class="red">'setEnabled'</span>, <span class="red">false</span>)</span>;
$(this).text('click to enable scroll');
} else {
$('aside')<span class="green">.simpleScrollFollow(<span class="red">'setEnabled'</span>, <span class="red">true</span>)</span>;
$(this).text('click to disable scroll');
}
});
</pre>
</div>
</section>
<section id="complex" class="card">
<h5 class="card-header">
<span lang="en">A more complex example</span>
<span lang="ja">複雑な使用例</span>
</h5>
<div class="card-body">
<div class="btn-container">
<a class="btn btn-primary" href="sample/complex/" target="_blank">
Sample
<svg class="octicon octicon-link-external" viewBox="0 0 12 16" version="1.1" aria-hidden="true"><path fill-rule="evenodd" d="M11 10h1v3c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h3v1H1v10h10v-3zM6 2l2.25 2.25L5 7.5 6.5 9l3.25-3.25L12 8V2H6z"></path></svg>
</a>
</div>
<p lang="en">
This plugin is also used in current page.
</p>
<p lang="ja">
なお、このページでもこのプラグインを利用しています。
</p>
</div>
</section>
</article>
</div><!-- .row -->
</div><!-- .container -->
<footer>
<div class="container">
powered by <a href="https://getbootstrap.com/">Bootstrap</a>
</div>
</footer>
<!-- JavaScript -->
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js"></script>
<script src="dist/jquery.simple-scroll-follow.min.js"></script>
<script src="sample/sample.js"></script>
</body>
</html>