-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
346 lines (316 loc) · 13.7 KB
/
index.html
File metadata and controls
346 lines (316 loc) · 13.7 KB
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
343
344
345
346
<!DOCTYPE html>
<html lang="en">
<head>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-76678048-11"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-76678048-11');
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>scrolls.js - JavaScript smooth scrolling library</title>
<link rel="canonical" href="https://scrollsjs.com/">
<meta name="description" content="scrolls.js is a tiny library to help provide smooth scrolling functionality for those that do not currently use another solution.">
<meta name="keywords" content="smooth scrolling, scroll, scroller, scrolling, back-to-top, welcome, homepage, landing page, Rob Dukarski, Dukarski, Purplest Inc, Purplest, Fort Wayne, Indiana">
<meta name="robots" content="noarchive">
<meta name="author" content="Rob Dukarski">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="scrolls.js - JavaScript smooth scrolling library">
<meta name="application-name" content="scrolls.js - JavaScript smooth scrolling library">
<meta name="msapplication-navbutton-color" content="#aa88ff">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="theme-color" content="#aa88ff">
<meta property="og:title" content="scrolls.js - JavaScript smooth scrolling library">
<meta property="og:site_name" content="scrolls.js">
<meta property="og:url" content="https://scrollsjs.com">
<meta property="og:description" content="scrolls.js is a tiny library to help provide smooth scrolling functionality for those that do not currently use another solution.">
<meta property="og:image" content="">
<meta property="og:type" content="website">
<meta property="og:locale" content="en-US">
<meta property="twitter:card" content="summary">
<meta property="twitter:title" content="scrolls.js - JavaScript smooth scrolling library">
<meta property="twitter:description" content="scrolls.js is a tiny library to help provide smooth scrolling functionality for those that do not currently use another solution.">
<meta property="twitter:creator" content="@PurplestInc">
<meta property="twitter:url" content="https://scrollsjs.com">
<meta property="twitter:image" content="">
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" href="static/css/main.css">
</head>
<body>
<div class="primary-design">
<div class="design">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
<header>
<h1>scrolls.js - smooth scrolling library</h1>
<ul class="stats">
<li>
<a href="https://github.com/PurplestInc/scrolls.js/blob/master/LICENSE" title="View the License"><img src="https://img.shields.io/badge/license-MIT-a8f.svg" alt="License: MIT"></a>
</li>
<li>
<a href="https://www.npmjs.com/package/scrolls.js" title="Go to the NPM landing page for scrolls.js"><img src="https://img.shields.io/npm/dt/scrolls.js.svg?colorB=a8f" alt="Total NPM Downloads"></a>
</li>
<li>
<a href="https://www.npmjs.com/package/scrolls.js#installation" title="Go to the installation section of the NPM landing page for scrolls.js"><img src="https://img.shields.io/npm/v/scrolls.js.svg?colorB=a8f" alt="Latest NPM Version"></a>
</li>
<li>
<a href="https://cdn.jsdelivr.net/npm/scrolls.js@1.0.18/scrolls.min.js?compression=gzip" title="Copy this link for the direct gzipped CDN file for scrolls.min.js"><img src="https://img.shields.io/badge/gzip%20size-453%20B-a8f.svg" alt="gzip size: 453 bytes"></a>
</li>
</ul>
<nav class="js-nav">
<a href="#basic-info" title="Basic Info">Basic Info</a>
<a href="#features" title="Features">Features</a>
<a href="#getting-started" title="Getting Started">Getting Started</a>
<a href="#installation" title="Installation">Installation</a>
<a href="#usage" title="Usage">Usage</a>
<a href="#examples" title="Examples">Examples</a>
<a href="#documentation" title="Documentation">Documentation</a>
<a href="#changelog" title="Changelog">Changelog</a>
<a href="#license" title="License">License</a>
</nav>
</header>
<main>
<h2 class="basic-info">Basic Info <button class="section-btt js-btt" title="Click to go back to the navigation bar, if necessary.">▲</button></h2>
<p>A smooth scrolling library built to provide convenience for developers.</p>
<p>If you like this project you may like our <a href="https://durationsjs.com?ref=scrollsjs.com" title="durations.js - animated durations library">durations.js</a> animated durations <a href="https://github.com/PurplestInc/durations.js" title="GitHub repo for durations.js">library</a>!</p>
<h2 class="features">Features <button class="section-btt js-btt" title="Click to go back to the navigation bar, if necessary.">▲</button></h2>
<ul>
<li>Plug-and-play (unless you have other JavaScript that uses <code>scrolls()</code> already...)</li>
<li>Number or selector-based targeting</li>
<li>Allows a function to be called when scrolling has ended</li>
<li>Customizeable duration of movement and offset position from the stop position</li>
<li>Fully open source</li>
</ul>
<h2 class="getting-started">Getting Started <button class="section-btt js-btt" title="Click to go back to the navigation bar, if necessary.">▲</button></h2>
<h3 class="installation">Installation</h3>
<p>You can install the libaray via npm:</p>
<pre class="code"><code>npm i scrolls.js</code></pre>
<p>or via CDN:</p>
<p>Source Version</p>
<pre class="code"><code><script src="https://cdn.jsdelivr.net/npm/scrolls.js@1.0.18/scrolls.js"></script></code></pre>
<p>Minified Version</p>
<pre class="code"><code><script src="https://cdn.jsdelivr.net/npm/scrolls.js@1.0.18/scrolls.min.js"></script></code></pre>
<h3 class="usage">Usage</h3>
<div>
<pre><code>scrolls(0); // Scroll to the top of the page.
scrolls('h1', {
durationOfMovement: 5000 // Defaults to 1000, or 1 second.
});
</code></pre>
</div>
<h2 class="examples">Examples <button class="section-btt js-btt" title="Click to go back to the navigation bar, if necessary.">▲</button></h2>
<h3>Back-To-Top</h3>
<p>HTML:</p>
<pre class="code"><code><button class="btt js-btt">&#x25b2;</button></code></pre>
<p>CSS:</p>
<pre class="code"><code><style>
/**
* Variables for matching this site's color scheme.
*/
html {
--primary-hue: 257;
--primary-saturation: 100%;
--primary-lightness: 77%;
--theme-lightness: 100%;
font-size: 16px;
}
.btt {
background: none;
background-color: hsla(var(--primary-hue), var(--primary-saturation), var(--primary-lightness), 0.75);
border: 0.063rem solid hsl(0, 0%, var(--theme-lightness));
bottom: -1.938rem;
color: hsl(0, 0%, var(--theme-lightness));
cursor: default;
font-family: 'Arial', sans-serif;
font-size: 1rem;
height: 1.875rem;
line-height: 1.25rem;
outline: none;
padding: 0.313rem;
position: fixed;
right: 0.625rem;
text-align: center;
transition: all 0.1s linear;
-webkit-appearance: none !important;
width: 1.875rem;
}
.btt.is--shown {
bottom: 0.625rem;
}
.btt:hover {
background-color: hsla(var(--primary-hue), var(--primary-saturation), calc(var(--primary-lightness) * 1.04), 0.85);
}
.btt:active {
background-color: hsla(var(--primary-hue), var(--primary-saturation), calc(var(--primary-lightness) * 0.96), 0.75);
}
</style>
</code></pre>
<p>JS:</p>
<pre class="code"><code><script src="https://cdn.jsdelivr.net/npm/scrolls.js@1.0.18/scrolls.min.js"></script>
<script>
/**
* Selects the back-to-top button.
*/
const bttButton = document.querySelector('body > .js-btt');
/**
* Scrolls to the top of the page.
*/
const backToTop = () => {
scrolls(0);
};
/**
* Hides the back-to-top button.
*/
const hideBackToTop = () => {
if (bttButton) {
bttButton.classList.remove('is--shown');
}
};
/**
* Shows the back-to-top button.
*/
const showBackToTop = () => {
if (bttButton) {
bttButton.classList.add('is--shown');
}
};
/**
* Listens for the scroll event to occur and updates the main back-to-top button
* accordingly.
*/
window.addEventListener('scroll', () => {
if (bttButton) {
if (window.pageYOffset >= 20) {
showBackToTop();
} else {
hideBackToTop();
}
}
});
/**
* Code setup to execute immediately including initializing events, and their
* liseners.
*/
(() => {
if (bttButton) {
bttButton.addEventListener('click', () => {
backToTop();
});
if (window.pageYOffset >= 20) {
showBackToTop();
}
}
})();
</script>
</code></pre>
<h3>Landing Page</h3>
<p>Are you building a landing page and want to have smooth scrolling from a navigation bar to the different sections of the page? Just copy-and-paste the code below, tweak it to match your environment, and you should have the section scrolling functionality you should be be able to experience here.</p>
<p>HTML:</p>
<pre class="code"><code><nav class="js-nav">
<a href="#features" title="Features">Features</a>
<a href="#pricing" title="Pricing">Pricing</a>
<a href="#team" title="Team">Team</a>
<a href="#contact" title="Contact">Contact</a>
</nav>
</code></pre>
<p>Somewhere further down or up the page...</p>
<pre class="code"><code><h2 class="features">Features</h2>
<!-- Features content -->
<h2 class="pricing">Pricing</h2>
<!-- Pricing content -->
<h2 class="team">Team</h2>
<!-- Team content -->
<h2 class="contact">Contact</h2>
<!-- Contact content -->
</code></pre>
<p>CSS:</p>
<pre class="code"><code><style>
nav {
text-align: center;
}
nav a {
margin: 0.625rem;
word-break: keep-all;
}
</style>
</code></pre>
<p>JS:</p>
<pre class="code"><code><script src="https://cdn.jsdelivr.net/npm/scrolls.js@1.0.18/scrolls.min.js"></script>
<script>
const links = document.querySelectorAll('.js-nav a');
/**
* Code setup to execute immediately including initializing events, and their
* liseners.
*/
(() => {
if (links) {
links.forEach((link) => {
const section = link.getAttribute('href').replace('#', '');
link.addEventListener('click', (e) => {
e.preventDefault();
scrolls('.' + section);
});
});
}
})();
</script>
</code></pre>
<p>That's it! If you copied the HTML and CSS from the Back-To-Top example from above you should have that functionality as well. Unless you have other code that would interfere with the selectors/styling you should be able to just plug-and-play with these examples!!</p>
<h2 class="documentation">Documentation <button class="section-btt js-btt" title="Click to go back to the navigation bar, if necessary.">▲</button></h2>
<pre><code>// Default customizeable variables via an object within the second parameter
// of the function.
let callback; // Function to execute after scrolling has ended
let durationOfMovement = 1000; // Duration of the scrolling
let offsetPosition = 0; // Distance to offset from the stop position
// Pass in an object as the second parameter to customize the behavior.
scrolls('h1', {
callback: () => {
console.log('Scrolling has finished.');
}
});
// The first parameter could be a number or string and is used as the target of
// the scrolling event, for example 0 would be the top of the page, or h1 to
// scroll to the first h1 element.
</code></pre>
<h2 class="changelog">Changelog <button class="section-btt js-btt" title="Click to go back to the navigation bar, if necessary.">▲</button></h2>
<p>Please see <a href="https://github.com/PurplestInc/scrolls.js/blob/master/CHANGELOG.md" title="CHANGELOG.md">CHANGELOG.md</a> for details.</p>
<h2 class="license">License <button class="section-btt js-btt" title="Click to go back to the navigation bar, if necessary.">▲</button></h2>
<p>MIT</p>
<p>Copyright © <span class="js-year">2018</span> <a class="brand-color" target="_blank" title="Purplest, Inc." href="https://purplest.com?ref=scrollsjs.com">Purplest, Inc.</a></p>
</main>
<button class="btt js-btt" title="Click to go back to the top of the page.">▲</button>
<footer>
<p>Copyright © <span class="js-year">2019</span> <a class="brand-color" target="_blank" title="Purplest, Inc." href="https://purplest.com?ref=scrollsjs.com">Purplest, Inc.</a></p>
<p>Built by: <a class="brand-color" target="_blank" title="Rob Dukarski's Portfolio" href="https://rob.dukar.ski?ref=scrollsjs.com">Rob Dukarski</a></p>
</footer>
<div class="secondary-design">
<div class="design">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
<div class="tertiary-design">
<div class="design">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/scrolls.js@1.0.18/scrolls.min.js"></script>
<script src="static/js/main.js"></script>
</body>
</html>