creek-jekyll-theme 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +81 -0
  4. data/_config.yml +306 -0
  5. data/_data/README.md +3 -0
  6. data/_data/navigation/docs.yml +56 -0
  7. data/_data/navigation/main.yml +12 -0
  8. data/_data/navigation.yml +68 -0
  9. data/_data/ui-text.yml +2024 -0
  10. data/_includes/analytics-providers/custom.html +3 -0
  11. data/_includes/analytics-providers/google-gtag.html +9 -0
  12. data/_includes/analytics-providers/google-universal.html +7 -0
  13. data/_includes/analytics-providers/google.html +14 -0
  14. data/_includes/analytics.html +14 -0
  15. data/_includes/archive-single.html +30 -0
  16. data/_includes/author-profile-custom-links.html +7 -0
  17. data/_includes/author-profile.html +246 -0
  18. data/_includes/breadcrumbs.html +40 -0
  19. data/_includes/browser-upgrade.html +2 -0
  20. data/_includes/category-list.html +19 -0
  21. data/_includes/comment.html +22 -0
  22. data/_includes/comments-providers/custom.html +3 -0
  23. data/_includes/comments-providers/custom_scripts.html +3 -0
  24. data/_includes/comments-providers/discourse.html +13 -0
  25. data/_includes/comments-providers/disqus.html +15 -0
  26. data/_includes/comments-providers/facebook.html +8 -0
  27. data/_includes/comments-providers/giscus.html +24 -0
  28. data/_includes/comments-providers/scripts.html +20 -0
  29. data/_includes/comments-providers/staticman.html +40 -0
  30. data/_includes/comments-providers/staticman_v2.html +40 -0
  31. data/_includes/comments-providers/utterances.html +21 -0
  32. data/_includes/comments.html +180 -0
  33. data/_includes/documents-collection.html +15 -0
  34. data/_includes/feature_row +41 -0
  35. data/_includes/figure +9 -0
  36. data/_includes/footer/custom.html +3 -0
  37. data/_includes/footer.html +21 -0
  38. data/_includes/gallery +35 -0
  39. data/_includes/group-by-array +47 -0
  40. data/_includes/head/custom.html +15 -0
  41. data/_includes/head.html +25 -0
  42. data/_includes/masthead.html +35 -0
  43. data/_includes/nav_list +26 -0
  44. data/_includes/page__date.html +6 -0
  45. data/_includes/page__hero.html +55 -0
  46. data/_includes/page__hero_video.html +2 -0
  47. data/_includes/page__meta.html +31 -0
  48. data/_includes/page__taxonomy.html +7 -0
  49. data/_includes/paginator.html +69 -0
  50. data/_includes/post_pagination.html +14 -0
  51. data/_includes/posts-category.html +5 -0
  52. data/_includes/posts-tag.html +5 -0
  53. data/_includes/scripts.html +28 -0
  54. data/_includes/search/algolia-search-scripts.html +62 -0
  55. data/_includes/search/google-search-scripts.html +30 -0
  56. data/_includes/search/lunr-search-scripts.html +10 -0
  57. data/_includes/search/search_form.html +26 -0
  58. data/_includes/seo.html +158 -0
  59. data/_includes/sidebar.html +19 -0
  60. data/_includes/skip-links.html +7 -0
  61. data/_includes/social-share.html +11 -0
  62. data/_includes/tag-list.html +19 -0
  63. data/_includes/toc +7 -0
  64. data/_includes/toc.html +182 -0
  65. data/_includes/video +24 -0
  66. data/_layouts/archive-taxonomy.html +29 -0
  67. data/_layouts/archive.html +26 -0
  68. data/_layouts/categories.html +43 -0
  69. data/_layouts/category.html +10 -0
  70. data/_layouts/collection.html +10 -0
  71. data/_layouts/compress.html +10 -0
  72. data/_layouts/default.html +41 -0
  73. data/_layouts/home.html +22 -0
  74. data/_layouts/posts.html +30 -0
  75. data/_layouts/search.html +42 -0
  76. data/_layouts/single.html +95 -0
  77. data/_layouts/splash.html +22 -0
  78. data/_layouts/tag.html +10 -0
  79. data/_layouts/tags.html +43 -0
  80. data/_pages/404.html +26 -0
  81. data/_sass/minimal-mistakes/_animations.scss +21 -0
  82. data/_sass/minimal-mistakes/_archive.scss +463 -0
  83. data/_sass/minimal-mistakes/_base.scss +339 -0
  84. data/_sass/minimal-mistakes/_buttons.scss +97 -0
  85. data/_sass/minimal-mistakes/_footer.scss +85 -0
  86. data/_sass/minimal-mistakes/_forms.scss +359 -0
  87. data/_sass/minimal-mistakes/_masthead.scss +93 -0
  88. data/_sass/minimal-mistakes/_mixins.scss +92 -0
  89. data/_sass/minimal-mistakes/_navigation.scss +573 -0
  90. data/_sass/minimal-mistakes/_notices.scss +109 -0
  91. data/_sass/minimal-mistakes/_page.scss +578 -0
  92. data/_sass/minimal-mistakes/_print.scss +252 -0
  93. data/_sass/minimal-mistakes/_reset.scss +187 -0
  94. data/_sass/minimal-mistakes/_search.scss +132 -0
  95. data/_sass/minimal-mistakes/_sidebar.scss +353 -0
  96. data/_sass/minimal-mistakes/_syntax.scss +324 -0
  97. data/_sass/minimal-mistakes/_tables.scss +39 -0
  98. data/_sass/minimal-mistakes/_utilities.scss +593 -0
  99. data/_sass/minimal-mistakes/_variables.scss +173 -0
  100. data/_sass/minimal-mistakes/skins/_air.scss +23 -0
  101. data/_sass/minimal-mistakes/skins/_aqua.scss +34 -0
  102. data/_sass/minimal-mistakes/skins/_contrast.scss +52 -0
  103. data/_sass/minimal-mistakes/skins/_dark.scss +30 -0
  104. data/_sass/minimal-mistakes/skins/_default.scss +5 -0
  105. data/_sass/minimal-mistakes/skins/_dirt.scss +33 -0
  106. data/_sass/minimal-mistakes/skins/_mint.scss +24 -0
  107. data/_sass/minimal-mistakes/skins/_neon.scss +63 -0
  108. data/_sass/minimal-mistakes/skins/_plum.scss +70 -0
  109. data/_sass/minimal-mistakes/skins/_sunrise.scss +49 -0
  110. data/_sass/minimal-mistakes/vendor/breakpoint/_breakpoint.scss +114 -0
  111. data/_sass/minimal-mistakes/vendor/breakpoint/_context.scss +95 -0
  112. data/_sass/minimal-mistakes/vendor/breakpoint/_helpers.scss +151 -0
  113. data/_sass/minimal-mistakes/vendor/breakpoint/_legacy-settings.scss +50 -0
  114. data/_sass/minimal-mistakes/vendor/breakpoint/_no-query.scss +15 -0
  115. data/_sass/minimal-mistakes/vendor/breakpoint/_parsers.scss +215 -0
  116. data/_sass/minimal-mistakes/vendor/breakpoint/_respond-to.scss +82 -0
  117. data/_sass/minimal-mistakes/vendor/breakpoint/_settings.scss +71 -0
  118. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_double.scss +33 -0
  119. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_query.scss +82 -0
  120. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_resolution.scss +31 -0
  121. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_single.scss +26 -0
  122. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_triple.scss +36 -0
  123. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/double/_default-pair.scss +21 -0
  124. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/double/_default.scss +22 -0
  125. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/double/_double-string.scss +22 -0
  126. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/resolution/_resolution.scss +60 -0
  127. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/single/_default.scss +13 -0
  128. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/triple/_default.scss +18 -0
  129. data/_sass/minimal-mistakes/vendor/magnific-popup/_magnific-popup.scss +649 -0
  130. data/_sass/minimal-mistakes/vendor/magnific-popup/_settings.scss +46 -0
  131. data/_sass/minimal-mistakes/vendor/susy/_su.scss +4 -0
  132. data/_sass/minimal-mistakes/vendor/susy/_susy-prefix.scss +13 -0
  133. data/_sass/minimal-mistakes/vendor/susy/_susy.scss +5 -0
  134. data/_sass/minimal-mistakes/vendor/susy/plugins/_svg-grid.scss +5 -0
  135. data/_sass/minimal-mistakes/vendor/susy/plugins/svg-grid/_prefix.scss +7 -0
  136. data/_sass/minimal-mistakes/vendor/susy/plugins/svg-grid/_svg-api.scss +114 -0
  137. data/_sass/minimal-mistakes/vendor/susy/plugins/svg-grid/_svg-grid-math.scss +67 -0
  138. data/_sass/minimal-mistakes/vendor/susy/plugins/svg-grid/_svg-settings.scss +14 -0
  139. data/_sass/minimal-mistakes/vendor/susy/plugins/svg-grid/_svg-unprefix.scss +18 -0
  140. data/_sass/minimal-mistakes/vendor/susy/plugins/svg-grid/_svg-utilities.scss +133 -0
  141. data/_sass/minimal-mistakes/vendor/susy/susy/_api.scss +318 -0
  142. data/_sass/minimal-mistakes/vendor/susy/susy/_normalize.scss +261 -0
  143. data/_sass/minimal-mistakes/vendor/susy/susy/_parse.scss +163 -0
  144. data/_sass/minimal-mistakes/vendor/susy/susy/_settings.scss +329 -0
  145. data/_sass/minimal-mistakes/vendor/susy/susy/_su-math.scss +441 -0
  146. data/_sass/minimal-mistakes/vendor/susy/susy/_su-validate.scss +213 -0
  147. data/_sass/minimal-mistakes/vendor/susy/susy/_syntax-helpers.scss +191 -0
  148. data/_sass/minimal-mistakes/vendor/susy/susy/_unprefix.scss +56 -0
  149. data/_sass/minimal-mistakes/vendor/susy/susy/_utilities.scss +167 -0
  150. data/_sass/minimal-mistakes.scss +40 -0
  151. data/assets/css/main.scss +9 -0
  152. data/assets/images/android-chrome-192x192.png +0 -0
  153. data/assets/images/android-chrome-512x512.png +0 -0
  154. data/assets/images/apple-touch-icon.png +0 -0
  155. data/assets/images/browserconfig.xml +9 -0
  156. data/assets/images/creek-logo.png +0 -0
  157. data/assets/images/favicon-16x16.png +0 -0
  158. data/assets/images/favicon-32x32.png +0 -0
  159. data/assets/images/favicon.ico +0 -0
  160. data/assets/images/mstile-150x150.png +0 -0
  161. data/assets/images/safari-pinned-tab.svg +48 -0
  162. data/assets/images/site-under-construction.png +0 -0
  163. data/assets/images/site.webmanifest +19 -0
  164. data/assets/js/_main.js +136 -0
  165. data/assets/js/lunr/lunr-en.js +73 -0
  166. data/assets/js/lunr/lunr-gr.js +526 -0
  167. data/assets/js/lunr/lunr-store.js +84 -0
  168. data/assets/js/lunr/lunr.js +3475 -0
  169. data/assets/js/lunr/lunr.min.js +6 -0
  170. data/assets/js/main.min.js +6 -0
  171. data/assets/js/plugins/gumshoe.js +484 -0
  172. data/assets/js/plugins/jquery.ba-throttle-debounce.js +252 -0
  173. data/assets/js/plugins/jquery.fitvids.js +82 -0
  174. data/assets/js/plugins/jquery.greedy-navigation.js +127 -0
  175. data/assets/js/plugins/jquery.magnific-popup.js +1860 -0
  176. data/assets/js/plugins/smooth-scroll.js +650 -0
  177. data/assets/js/vendor/jquery/jquery-3.6.0.js +10881 -0
  178. metadata +233 -0
@@ -0,0 +1,650 @@
1
+ /*!
2
+ * smooth-scroll v16.1.2
3
+ * Animate scrolling to anchor links
4
+ * (c) 2020 Chris Ferdinandi
5
+ * MIT License
6
+ * http://github.com/cferdinandi/smooth-scroll
7
+ */
8
+
9
+ (function (root, factory) {
10
+ if (typeof define === 'function' && define.amd) {
11
+ define([], (function () {
12
+ return factory(root);
13
+ }));
14
+ } else if (typeof exports === 'object') {
15
+ module.exports = factory(root);
16
+ } else {
17
+ root.SmoothScroll = factory(root);
18
+ }
19
+ })(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this, (function (window) {
20
+
21
+ 'use strict';
22
+
23
+ //
24
+ // Default settings
25
+ //
26
+
27
+ var defaults = {
28
+
29
+ // Selectors
30
+ ignore: '[data-scroll-ignore]',
31
+ header: null,
32
+ topOnEmptyHash: true,
33
+
34
+ // Speed & Duration
35
+ speed: 500,
36
+ speedAsDuration: false,
37
+ durationMax: null,
38
+ durationMin: null,
39
+ clip: true,
40
+ offset: 0,
41
+
42
+ // Easing
43
+ easing: 'easeInOutCubic',
44
+ customEasing: null,
45
+
46
+ // History
47
+ updateURL: true,
48
+ popstate: true,
49
+
50
+ // Custom Events
51
+ emitEvents: true
52
+
53
+ };
54
+
55
+
56
+ //
57
+ // Utility Methods
58
+ //
59
+
60
+ /**
61
+ * Check if browser supports required methods
62
+ * @return {Boolean} Returns true if all required methods are supported
63
+ */
64
+ var supports = function () {
65
+ return (
66
+ 'querySelector' in document &&
67
+ 'addEventListener' in window &&
68
+ 'requestAnimationFrame' in window &&
69
+ 'closest' in window.Element.prototype
70
+ );
71
+ };
72
+
73
+ /**
74
+ * Merge two or more objects together.
75
+ * @param {Object} objects The objects to merge together
76
+ * @returns {Object} Merged values of defaults and options
77
+ */
78
+ var extend = function () {
79
+ var merged = {};
80
+ Array.prototype.forEach.call(arguments, (function (obj) {
81
+ for (var key in obj) {
82
+ if (!obj.hasOwnProperty(key)) return;
83
+ merged[key] = obj[key];
84
+ }
85
+ }));
86
+ return merged;
87
+ };
88
+
89
+ /**
90
+ * Check to see if user prefers reduced motion
91
+ * @param {Object} settings Script settings
92
+ */
93
+ var reduceMotion = function () {
94
+ if ('matchMedia' in window && window.matchMedia('(prefers-reduced-motion)').matches) {
95
+ return true;
96
+ }
97
+ return false;
98
+ };
99
+
100
+ /**
101
+ * Get the height of an element.
102
+ * @param {Node} elem The element to get the height of
103
+ * @return {Number} The element's height in pixels
104
+ */
105
+ var getHeight = function (elem) {
106
+ return parseInt(window.getComputedStyle(elem).height, 10);
107
+ };
108
+
109
+ /**
110
+ * Escape special characters for use with querySelector
111
+ * @author Mathias Bynens
112
+ * @link https://github.com/mathiasbynens/CSS.escape
113
+ * @param {String} id The anchor ID to escape
114
+ */
115
+ var escapeCharacters = function (id) {
116
+
117
+ // Remove leading hash
118
+ if (id.charAt(0) === '#') {
119
+ id = id.substr(1);
120
+ }
121
+
122
+ var string = String(id);
123
+ var length = string.length;
124
+ var index = -1;
125
+ var codeUnit;
126
+ var result = '';
127
+ var firstCodeUnit = string.charCodeAt(0);
128
+ while (++index < length) {
129
+ codeUnit = string.charCodeAt(index);
130
+ // Note: there’s no need to special-case astral symbols, surrogate
131
+ // pairs, or lone surrogates.
132
+
133
+ // If the character is NULL (U+0000), then throw an
134
+ // `InvalidCharacterError` exception and terminate these steps.
135
+ if (codeUnit === 0x0000) {
136
+ throw new InvalidCharacterError(
137
+ 'Invalid character: the input contains U+0000.'
138
+ );
139
+ }
140
+
141
+ if (
142
+ // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
143
+ // U+007F, […]
144
+ (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
145
+ // If the character is the first character and is in the range [0-9]
146
+ // (U+0030 to U+0039), […]
147
+ (index === 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
148
+ // If the character is the second character and is in the range [0-9]
149
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
150
+ (
151
+ index === 1 &&
152
+ codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
153
+ firstCodeUnit === 0x002D
154
+ )
155
+ ) {
156
+ // http://dev.w3.org/csswg/cssom/#escape-a-character-as-code-point
157
+ result += '\\' + codeUnit.toString(16) + ' ';
158
+ continue;
159
+ }
160
+
161
+ // If the character is not handled by one of the above rules and is
162
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
163
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
164
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
165
+ if (
166
+ codeUnit >= 0x0080 ||
167
+ codeUnit === 0x002D ||
168
+ codeUnit === 0x005F ||
169
+ codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
170
+ codeUnit >= 0x0041 && codeUnit <= 0x005A ||
171
+ codeUnit >= 0x0061 && codeUnit <= 0x007A
172
+ ) {
173
+ // the character itself
174
+ result += string.charAt(index);
175
+ continue;
176
+ }
177
+
178
+ // Otherwise, the escaped character.
179
+ // http://dev.w3.org/csswg/cssom/#escape-a-character
180
+ result += '\\' + string.charAt(index);
181
+
182
+ }
183
+
184
+ // Return sanitized hash
185
+ return '#' + result;
186
+
187
+ };
188
+
189
+ /**
190
+ * Calculate the easing pattern
191
+ * @link https://gist.github.com/gre/1650294
192
+ * @param {String} type Easing pattern
193
+ * @param {Number} time Time animation should take to complete
194
+ * @returns {Number}
195
+ */
196
+ var easingPattern = function (settings, time) {
197
+ var pattern;
198
+
199
+ // Default Easing Patterns
200
+ if (settings.easing === 'easeInQuad') pattern = time * time; // accelerating from zero velocity
201
+ if (settings.easing === 'easeOutQuad') pattern = time * (2 - time); // decelerating to zero velocity
202
+ if (settings.easing === 'easeInOutQuad') pattern = time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; // acceleration until halfway, then deceleration
203
+ if (settings.easing === 'easeInCubic') pattern = time * time * time; // accelerating from zero velocity
204
+ if (settings.easing === 'easeOutCubic') pattern = (--time) * time * time + 1; // decelerating to zero velocity
205
+ if (settings.easing === 'easeInOutCubic') pattern = time < 0.5 ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1; // acceleration until halfway, then deceleration
206
+ if (settings.easing === 'easeInQuart') pattern = time * time * time * time; // accelerating from zero velocity
207
+ if (settings.easing === 'easeOutQuart') pattern = 1 - (--time) * time * time * time; // decelerating to zero velocity
208
+ if (settings.easing === 'easeInOutQuart') pattern = time < 0.5 ? 8 * time * time * time * time : 1 - 8 * (--time) * time * time * time; // acceleration until halfway, then deceleration
209
+ if (settings.easing === 'easeInQuint') pattern = time * time * time * time * time; // accelerating from zero velocity
210
+ if (settings.easing === 'easeOutQuint') pattern = 1 + (--time) * time * time * time * time; // decelerating to zero velocity
211
+ if (settings.easing === 'easeInOutQuint') pattern = time < 0.5 ? 16 * time * time * time * time * time : 1 + 16 * (--time) * time * time * time * time; // acceleration until halfway, then deceleration
212
+
213
+ // Custom Easing Patterns
214
+ if (!!settings.customEasing) pattern = settings.customEasing(time);
215
+
216
+ return pattern || time; // no easing, no acceleration
217
+ };
218
+
219
+ /**
220
+ * Determine the document's height
221
+ * @returns {Number}
222
+ */
223
+ var getDocumentHeight = function () {
224
+ return Math.max(
225
+ document.body.scrollHeight, document.documentElement.scrollHeight,
226
+ document.body.offsetHeight, document.documentElement.offsetHeight,
227
+ document.body.clientHeight, document.documentElement.clientHeight
228
+ );
229
+ };
230
+
231
+ /**
232
+ * Calculate how far to scroll
233
+ * Clip support added by robjtede - https://github.com/cferdinandi/smooth-scroll/issues/405
234
+ * @param {Element} anchor The anchor element to scroll to
235
+ * @param {Number} headerHeight Height of a fixed header, if any
236
+ * @param {Number} offset Number of pixels by which to offset scroll
237
+ * @param {Boolean} clip If true, adjust scroll distance to prevent abrupt stops near the bottom of the page
238
+ * @returns {Number}
239
+ */
240
+ var getEndLocation = function (anchor, headerHeight, offset, clip) {
241
+ var location = 0;
242
+ if (anchor.offsetParent) {
243
+ do {
244
+ location += anchor.offsetTop;
245
+ anchor = anchor.offsetParent;
246
+ } while (anchor);
247
+ }
248
+ location = Math.max(location - headerHeight - offset, 0);
249
+ if (clip) {
250
+ location = Math.min(location, getDocumentHeight() - window.innerHeight);
251
+ }
252
+ return location;
253
+ };
254
+
255
+ /**
256
+ * Get the height of the fixed header
257
+ * @param {Node} header The header
258
+ * @return {Number} The height of the header
259
+ */
260
+ var getHeaderHeight = function (header) {
261
+ return !header ? 0 : (getHeight(header) + header.offsetTop);
262
+ };
263
+
264
+ /**
265
+ * Calculate the speed to use for the animation
266
+ * @param {Number} distance The distance to travel
267
+ * @param {Object} settings The plugin settings
268
+ * @return {Number} How fast to animate
269
+ */
270
+ var getSpeed = function (distance, settings) {
271
+ var speed = settings.speedAsDuration ? settings.speed : Math.abs(distance / 1000 * settings.speed);
272
+ if (settings.durationMax && speed > settings.durationMax) return settings.durationMax;
273
+ if (settings.durationMin && speed < settings.durationMin) return settings.durationMin;
274
+ return parseInt(speed, 10);
275
+ };
276
+
277
+ var setHistory = function (options) {
278
+
279
+ // Make sure this should run
280
+ if (!history.replaceState || !options.updateURL || history.state) return;
281
+
282
+ // Get the hash to use
283
+ var hash = window.location.hash;
284
+ hash = hash ? hash : '';
285
+
286
+ // Set a default history
287
+ history.replaceState(
288
+ {
289
+ smoothScroll: JSON.stringify(options),
290
+ anchor: hash ? hash : window.pageYOffset
291
+ },
292
+ document.title,
293
+ hash ? hash : window.location.href
294
+ );
295
+
296
+ };
297
+
298
+ /**
299
+ * Update the URL
300
+ * @param {Node} anchor The anchor that was scrolled to
301
+ * @param {Boolean} isNum If true, anchor is a number
302
+ * @param {Object} options Settings for Smooth Scroll
303
+ */
304
+ var updateURL = function (anchor, isNum, options) {
305
+
306
+ // Bail if the anchor is a number
307
+ if (isNum) return;
308
+
309
+ // Verify that pushState is supported and the updateURL option is enabled
310
+ if (!history.pushState || !options.updateURL) return;
311
+
312
+ // Update URL
313
+ history.pushState(
314
+ {
315
+ smoothScroll: JSON.stringify(options),
316
+ anchor: anchor.id
317
+ },
318
+ document.title,
319
+ anchor === document.documentElement ? '#top' : '#' + anchor.id
320
+ );
321
+
322
+ };
323
+
324
+ /**
325
+ * Bring the anchored element into focus
326
+ * @param {Node} anchor The anchor element
327
+ * @param {Number} endLocation The end location to scroll to
328
+ * @param {Boolean} isNum If true, scroll is to a position rather than an element
329
+ */
330
+ var adjustFocus = function (anchor, endLocation, isNum) {
331
+
332
+ // Is scrolling to top of page, blur
333
+ if (anchor === 0) {
334
+ document.body.focus();
335
+ }
336
+
337
+ // Don't run if scrolling to a number on the page
338
+ if (isNum) return;
339
+
340
+ // Otherwise, bring anchor element into focus
341
+ anchor.focus();
342
+ if (document.activeElement !== anchor) {
343
+ anchor.setAttribute('tabindex', '-1');
344
+ anchor.focus();
345
+ anchor.style.outline = 'none';
346
+ }
347
+ window.scrollTo(0 , endLocation);
348
+
349
+ };
350
+
351
+ /**
352
+ * Emit a custom event
353
+ * @param {String} type The event type
354
+ * @param {Object} options The settings object
355
+ * @param {Node} anchor The anchor element
356
+ * @param {Node} toggle The toggle element
357
+ */
358
+ var emitEvent = function (type, options, anchor, toggle) {
359
+ if (!options.emitEvents || typeof window.CustomEvent !== 'function') return;
360
+ var event = new CustomEvent(type, {
361
+ bubbles: true,
362
+ detail: {
363
+ anchor: anchor,
364
+ toggle: toggle
365
+ }
366
+ });
367
+ document.dispatchEvent(event);
368
+ };
369
+
370
+
371
+ //
372
+ // SmoothScroll Constructor
373
+ //
374
+
375
+ var SmoothScroll = function (selector, options) {
376
+
377
+ //
378
+ // Variables
379
+ //
380
+
381
+ var smoothScroll = {}; // Object for public APIs
382
+ var settings, anchor, toggle, fixedHeader, eventTimeout, animationInterval;
383
+
384
+
385
+ //
386
+ // Methods
387
+ //
388
+
389
+ /**
390
+ * Cancel a scroll-in-progress
391
+ */
392
+ smoothScroll.cancelScroll = function (noEvent) {
393
+ cancelAnimationFrame(animationInterval);
394
+ animationInterval = null;
395
+ if (noEvent) return;
396
+ emitEvent('scrollCancel', settings);
397
+ };
398
+
399
+ /**
400
+ * Start/stop the scrolling animation
401
+ * @param {Node|Number} anchor The element or position to scroll to
402
+ * @param {Element} toggle The element that toggled the scroll event
403
+ * @param {Object} options
404
+ */
405
+ smoothScroll.animateScroll = function (anchor, toggle, options) {
406
+
407
+ // Cancel any in progress scrolls
408
+ smoothScroll.cancelScroll();
409
+
410
+ // Local settings
411
+ var _settings = extend(settings || defaults, options || {}); // Merge user options with defaults
412
+
413
+ // Selectors and variables
414
+ var isNum = Object.prototype.toString.call(anchor) === '[object Number]' ? true : false;
415
+ var anchorElem = isNum || !anchor.tagName ? null : anchor;
416
+ if (!isNum && !anchorElem) return;
417
+ var startLocation = window.pageYOffset; // Current location on the page
418
+ if (_settings.header && !fixedHeader) {
419
+ // Get the fixed header if not already set
420
+ fixedHeader = document.querySelector(_settings.header);
421
+ }
422
+ var headerHeight = getHeaderHeight(fixedHeader);
423
+ var endLocation = isNum ? anchor : getEndLocation(anchorElem, headerHeight, parseInt((typeof _settings.offset === 'function' ? _settings.offset(anchor, toggle) : _settings.offset), 10), _settings.clip); // Location to scroll to
424
+ var distance = endLocation - startLocation; // distance to travel
425
+ var documentHeight = getDocumentHeight();
426
+ var timeLapsed = 0;
427
+ var speed = getSpeed(distance, _settings);
428
+ var start, percentage, position;
429
+
430
+ /**
431
+ * Stop the scroll animation when it reaches its target (or the bottom/top of page)
432
+ * @param {Number} position Current position on the page
433
+ * @param {Number} endLocation Scroll to location
434
+ * @param {Number} animationInterval How much to scroll on this loop
435
+ */
436
+ var stopAnimateScroll = function (position, endLocation) {
437
+
438
+ // Get the current location
439
+ var currentLocation = window.pageYOffset;
440
+
441
+ // Check if the end location has been reached yet (or we've hit the end of the document)
442
+ if (position == endLocation || currentLocation == endLocation || ((startLocation < endLocation && window.innerHeight + currentLocation) >= documentHeight)) {
443
+
444
+ // Clear the animation timer
445
+ smoothScroll.cancelScroll(true);
446
+
447
+ // Bring the anchored element into focus
448
+ adjustFocus(anchor, endLocation, isNum);
449
+
450
+ // Emit a custom event
451
+ emitEvent('scrollStop', _settings, anchor, toggle);
452
+
453
+ // Reset start
454
+ start = null;
455
+ animationInterval = null;
456
+
457
+ return true;
458
+
459
+ }
460
+ };
461
+
462
+ /**
463
+ * Loop scrolling animation
464
+ */
465
+ var loopAnimateScroll = function (timestamp) {
466
+ if (!start) { start = timestamp; }
467
+ timeLapsed += timestamp - start;
468
+ percentage = speed === 0 ? 0 : (timeLapsed / speed);
469
+ percentage = (percentage > 1) ? 1 : percentage;
470
+ position = startLocation + (distance * easingPattern(_settings, percentage));
471
+ window.scrollTo(0, Math.floor(position));
472
+ if (!stopAnimateScroll(position, endLocation)) {
473
+ animationInterval = window.requestAnimationFrame(loopAnimateScroll);
474
+ start = timestamp;
475
+ }
476
+ };
477
+
478
+ /**
479
+ * Reset position to fix weird iOS bug
480
+ * @link https://github.com/cferdinandi/smooth-scroll/issues/45
481
+ */
482
+ if (window.pageYOffset === 0) {
483
+ window.scrollTo(0, 0);
484
+ }
485
+
486
+ // Update the URL
487
+ updateURL(anchor, isNum, _settings);
488
+
489
+ // If the user prefers reduced motion, jump to location
490
+ if (reduceMotion()) {
491
+ window.scrollTo(0, Math.floor(endLocation));
492
+ return;
493
+ }
494
+
495
+ // Emit a custom event
496
+ emitEvent('scrollStart', _settings, anchor, toggle);
497
+
498
+ // Start scrolling animation
499
+ smoothScroll.cancelScroll(true);
500
+ window.requestAnimationFrame(loopAnimateScroll);
501
+
502
+ };
503
+
504
+ /**
505
+ * If smooth scroll element clicked, animate scroll
506
+ */
507
+ var clickHandler = function (event) {
508
+
509
+ // Don't run if event was canceled but still bubbled up
510
+ // By @mgreter - https://github.com/cferdinandi/smooth-scroll/pull/462/
511
+ if (event.defaultPrevented) return;
512
+
513
+ // Don't run if right-click or command/control + click or shift + click
514
+ if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey) return;
515
+
516
+ // Check if event.target has closest() method
517
+ // By @totegi - https://github.com/cferdinandi/smooth-scroll/pull/401/
518
+ if (!('closest' in event.target)) return;
519
+
520
+ // Check if a smooth scroll link was clicked
521
+ toggle = event.target.closest(selector);
522
+ if (!toggle || toggle.tagName.toLowerCase() !== 'a' || event.target.closest(settings.ignore)) return;
523
+
524
+ // Only run if link is an anchor and points to the current page
525
+ if (toggle.hostname !== window.location.hostname || toggle.pathname !== window.location.pathname || !/#/.test(toggle.href)) return;
526
+
527
+ // Get an escaped version of the hash
528
+ var hash;
529
+ try {
530
+ hash = escapeCharacters(decodeURIComponent(toggle.hash));
531
+ } catch(e) {
532
+ hash = escapeCharacters(toggle.hash);
533
+ }
534
+
535
+ // Get the anchored element
536
+ var anchor;
537
+ if (hash === '#') {
538
+ if (!settings.topOnEmptyHash) return;
539
+ anchor = document.documentElement;
540
+ } else {
541
+ anchor = document.querySelector(hash);
542
+ }
543
+ anchor = !anchor && hash === '#top' ? document.documentElement : anchor;
544
+
545
+ // If anchored element exists, scroll to it
546
+ if (!anchor) return;
547
+ event.preventDefault();
548
+ setHistory(settings);
549
+ smoothScroll.animateScroll(anchor, toggle);
550
+
551
+ };
552
+
553
+ /**
554
+ * Animate scroll on popstate events
555
+ */
556
+ var popstateHandler = function (event) {
557
+
558
+ // Stop if history.state doesn't exist (ex. if clicking on a broken anchor link).
559
+ // fixes `Cannot read property 'smoothScroll' of null` error getting thrown.
560
+ if (history.state === null) return;
561
+
562
+ // Only run if state is a popstate record for this instantiation
563
+ if (!history.state.smoothScroll || history.state.smoothScroll !== JSON.stringify(settings)) return;
564
+
565
+ // Only run if state includes an anchor
566
+
567
+ // if (!history.state.anchor && history.state.anchor !== 0) return;
568
+
569
+ // Get the anchor
570
+ var anchor = history.state.anchor;
571
+ if (typeof anchor === 'string' && anchor) {
572
+ anchor = document.querySelector(escapeCharacters(history.state.anchor));
573
+ if (!anchor) return;
574
+ }
575
+
576
+ // Animate scroll to anchor link
577
+ smoothScroll.animateScroll(anchor, null, {updateURL: false});
578
+
579
+ };
580
+
581
+ /**
582
+ * Destroy the current initialization.
583
+ */
584
+ smoothScroll.destroy = function () {
585
+
586
+ // If plugin isn't already initialized, stop
587
+ if (!settings) return;
588
+
589
+ // Remove event listeners
590
+ document.removeEventListener('click', clickHandler, false);
591
+ window.removeEventListener('popstate', popstateHandler, false);
592
+
593
+ // Cancel any scrolls-in-progress
594
+ smoothScroll.cancelScroll();
595
+
596
+ // Reset variables
597
+ settings = null;
598
+ anchor = null;
599
+ toggle = null;
600
+ fixedHeader = null;
601
+ eventTimeout = null;
602
+ animationInterval = null;
603
+
604
+ };
605
+
606
+ /**
607
+ * Initialize Smooth Scroll
608
+ * @param {Object} options User settings
609
+ */
610
+ var init = function () {
611
+
612
+ // feature test
613
+ if (!supports()) throw 'Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.';
614
+
615
+ // Destroy any existing initializations
616
+ smoothScroll.destroy();
617
+
618
+ // Selectors and variables
619
+ settings = extend(defaults, options || {}); // Merge user options with defaults
620
+ fixedHeader = settings.header ? document.querySelector(settings.header) : null; // Get the fixed header
621
+
622
+ // When a toggle is clicked, run the click handler
623
+ document.addEventListener('click', clickHandler, false);
624
+
625
+ // If updateURL and popState are enabled, listen for pop events
626
+ if (settings.updateURL && settings.popstate) {
627
+ window.addEventListener('popstate', popstateHandler, false);
628
+ }
629
+
630
+ };
631
+
632
+
633
+ //
634
+ // Initialize plugin
635
+ //
636
+
637
+ init();
638
+
639
+
640
+ //
641
+ // Public APIs
642
+ //
643
+
644
+ return smoothScroll;
645
+
646
+ };
647
+
648
+ return SmoothScroll;
649
+
650
+ }));