Skip to content

Commit 6747aab

Browse files
Upped the version to 1.0.3. Moved the scrollTop limiter to the Frame Loop.
1 parent b1e4bad commit 6747aab

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "midnight",
3-
"version": "1.0.1",
3+
"version": "1.0.3",
44
"description": "Switch fixed headers on the fly",
55
"main": "midnight.jquery.js",
66
"homepage": "https://github.com/Aerolab/midnight.js",

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868

6969
<div class="top-links" data-midnight="white">
70-
<a class="button" href="https://aerolab.github.io/midnight.js/midnight.jquery.js" download>Download</a>
70+
<a class="button" href="https://aerolab.github.io/midnight.js/midnight.jquery.min.js" download>Download</a>
7171
<a class="button button-github" href="https://github.com/Aerolab/midnight.js" target="_blank">Fork on GitHub</a>
7272
</div>
7373

@@ -172,7 +172,7 @@ <h2>The jQuery Plugin</h2>
172172
<p>To make everything work, just load midnight (and jQuery) and initialize it. We take care of the rest.</p>
173173
</div>
174174

175-
<pre class="line-numbers wow fadeInRight"><code class="language-markup">&lt;script src="https://github.com/midnight.jquery.js"&gt;&lt;/script&gt;
175+
<pre class="line-numbers wow fadeInRight"><code class="language-markup">&lt;script src="https://github.com/midnight.jquery.%3Cspan%20class="x x-first x-last">min.js"&gt;&lt;/script&gt;
176176
&lt;script&gt;
177177
// Start midnight
178178
$(document).ready(function(){
@@ -224,7 +224,7 @@ <h2>Further customization</h2>
224224

225225
<div class="container">
226226
<div class="buttons wow fadeIn">
227-
<a class="button" href="https://aerolab.github.io/midnight.js/midnight.jquery.js" download>Download</a>
227+
<a class="button" href="https://aerolab.github.io/midnight.js/midnight.jquery.min.js" download>Download</a>
228228
<a class="button" href="https://github.com/Aerolab/midnight.js" target="_blank"><i class="icon-github"></i> Fork on GitHub</a>
229229
</div>
230230
</div>
@@ -243,7 +243,7 @@ <h2>Further customization</h2>
243243
<script src="assets/js/prism.js"></script>
244244
<script src="assets/js/wow.min.js"></script>
245245
<script src="assets/js/viewport-units-buggyfill.js"></script>
246-
<script src="midnight.jquery.js"></script>
246+
<script src="midnight.jquery.min.js"></script>
247247
<script>
248248

249249

midnight.jquery.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Midnight.js 1.0.2
2+
* Midnight.js 1.0.3
33
* jQuery plugin to switch between multiple fixed header designs on the fly, so it looks in line with the content below it.
44
* http://aerolab.github.io/midnight.js/
55
*
@@ -37,6 +37,7 @@
3737

3838
// Scroll Cache
3939
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
40+
var documentHeight = $(document).height();
4041

4142
// Cache all the switchable headers (different colors)
4243
var $originalHeader = $(this);
@@ -232,6 +233,8 @@
232233

233234
var recalculateSections = function(){
234235

236+
documentHeight = $(document).height();
237+
235238
// Cache all the sections and their start/end positions (where the class starts and ends)
236239
sections = [];
237240

@@ -260,7 +263,7 @@
260263
scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
261264
// Some browsers (e.g on OS X) allow scrolling past the top/bottom.
262265
scrollTop = Math.max(scrollTop, 0);
263-
scrollTop = Math.min(scrollTop, $(document).height());
266+
scrollTop = Math.min(scrollTop, documentHeight);
264267

265268
// Get the header's position relative to the document (given that it's fixed)
266269
var headerHeight = headerInfo.height;

midnight.jquery.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

midnight.jquery.src.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
// Scroll Cache
2929
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
30+
var documentHeight = $(document).height();
3031

3132
// Cache all the switchable headers (different colors)
3233
var $originalHeader = $(this);
@@ -222,6 +223,8 @@
222223

223224
var recalculateSections = function(){
224225

226+
documentHeight = $(document).height();
227+
225228
// Cache all the sections and their start/end positions (where the class starts and ends)
226229
sections = [];
227230

@@ -248,6 +251,9 @@
248251

249252
// Check classes are currently active in the header (including the current percentage of each)
250253
scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
254+
// Some browsers (e.g on OS X) allow scrolling past the top/bottom.
255+
scrollTop = Math.max(scrollTop, 0);
256+
scrollTop = Math.min(scrollTop, documentHeight);
251257

252258
// Get the header's position relative to the document (given that it's fixed)
253259
var headerHeight = headerInfo.height;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Midnight.JS",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A jQuery plugin to switch fixed headers on the fly",
55
"devDependencies": {
66
"gulp": "^3.8.8",

0 commit comments

Comments
 (0)