Skip to content

Commit 62a59ea

Browse files
author
Daniel Li
committed
Fixing lethargy integration
1 parent 425998d commit 62a59ea

File tree

10 files changed

+28
-13
lines changed

10 files changed

+28
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# smartscroll
22

3-
smartscroll is a tiny (1046b minfied + gzipped) jQuery plugin that has these *independent* features:
3+
smartscroll is a tiny (1048b minfied + gzipped) jQuery plugin that has these *independent* features:
44

55
1. Section scrolling - Scrolljacking
66
2. Auto-hash - Updates the URL hash based on current position on page

examples/auto-hash/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="section" data-hash="a">
1313
<div>
1414
<h1>smartscroll - Auto-Hash</h1>
15-
<p>A tiny (1046b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
15+
<p>A tiny (1048b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
1616
<p>See it on <a href="https://github.com/d4nyll/smartscroll" target="_blank">GitHub</a>, or see some <a href="http://blog.danyll.com/smartscroll-jquery-scrolljacking-plugin/" target="_blank">comparisons</a></p>
1717
<p>Try out other examples!</p>
1818
<ul>
@@ -44,6 +44,7 @@ <h1>smartscroll - Auto-Hash</h1>
4444
</div>
4545
</div>
4646
<script type="text/javascript" src="../../bower_components/lethargy/lethargy.min.js"></script>
47+
<script type="text/javascript" src="../../smartscroll.js"></script>
4748
<script>
4849
$.smartscroll({
4950
autoHash: true,

examples/different-heights/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="section" data-hash="a">
1313
<div>
1414
<h1>smartscroll - Different Heights</h1>
15-
<p>A tiny (1046b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
15+
<p>A tiny (1048b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
1616
<p>See it on <a href="https://github.com/d4nyll/smartscroll" target="_blank">GitHub</a>, or see some <a href="http://blog.danyll.com/smartscroll-jquery-scrolljacking-plugin/" target="_blank">comparisons</a></p>
1717
<p>Try out other examples!</p>
1818
<ul>
@@ -43,6 +43,7 @@ <h1>smartscroll - Different Heights</h1>
4343
</div>
4444
</div>
4545
<script type="text/javascript" src="../../bower_components/lethargy/lethargy.min.js"></script>
46+
<script type="text/javascript" src="../../smartscroll.js"></script>
4647
<script>
4748
$.smartscroll({
4849
mode: "set"

examples/hybrid-scroll/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div class="header">
1212
<div>
1313
<h1>smartscroll - Hybrid Scroll</h1>
14-
<p>A tiny (1046b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
14+
<p>A tiny (1048b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
1515
<p>See it on <a href="https://github.com/d4nyll/smartscroll" target="_blank">GitHub</a>, or see some <a href="http://blog.danyll.com/smartscroll-jquery-scrolljacking-plugin/" target="_blank">comparisons</a></p>
1616
<p>Try out other examples!</p>
1717
<ul>
@@ -51,6 +51,7 @@ <h1>Hybrid Scroll</h1>
5151
</div>
5252
</div>
5353
<script type="text/javascript" src="../../bower_components/lethargy/lethargy.min.js"></script>
54+
<script type="text/javascript" src="../../smartscroll.js"></script>
5455
<script>
5556
$.smartscroll({});
5657
</script>

examples/index.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div class="header">
1212
<div>
1313
<h1>smartscroll</h1>
14-
<p>A tiny (1046b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
14+
<p>A tiny (1048b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
1515
<p>See it on <a href="https://github.com/d4nyll/smartscroll" target="_blank">GitHub</a>, or see some <a href="http://blog.danyll.com/smartscroll-jquery-scrolljacking-plugin/" target="_blank">comparisons</a></p>
1616
<p>Try out other examples!</p>
1717
<ul>
@@ -21,6 +21,7 @@ <h1>smartscroll</h1>
2121
<li><a href="http://d4nyll.github.io/smartscroll/hybrid-scroll/">Hybrid Scroll</a></li>
2222
<li><a href="http://d4nyll.github.io/smartscroll/auto-hash/">Auto-Hash</a></li>
2323
<li><a href="http://d4nyll.github.io/smartscroll/keep-history/">Keep History</a></li>
24+
<li><a href="http://d4nyll.github.io/smartscroll/responsive/">Keep History</a></li>
2425
</ul>
2526
</div>
2627
</div>
@@ -71,8 +72,16 @@ <h1>Keep History</h1>
7172
<a href="http://d4nyll.github.io/smartscroll/keep-history/">Demo</a>
7273
</div>
7374
</div>
75+
<div class="section" data-hash="responsive">
76+
<div>
77+
<h1>Responsive</h1>
78+
<p>You can disable section scrolling for windows below a certain width. Do not confuse this with touch devices, where scrolljacking is disabled by design.</p>
79+
<a href="http://d4nyll.github.io/smartscroll/responsive/">Demo</a>
80+
</div>
81+
</div>
7482
</div>
7583
<script type="text/javascript" src="../bower_components/lethargy/lethargy.min.js"></script>
84+
<script type="text/javascript" src="../smartscroll.js"></script>
7685
<script>
7786
$.smartscroll({
7887
sectionWrapperSelector: ".section-wrapper",

examples/keep-history/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="section" data-hash="a">
1313
<div>
1414
<h1>smartscroll - Keep History</h1>
15-
<p>A tiny (1046b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
15+
<p>A tiny (1048b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
1616
<p>See it on <a href="https://github.com/d4nyll/smartscroll" target="_blank">GitHub</a>, or see some <a href="http://blog.danyll.com/smartscroll-jquery-scrolljacking-plugin/" target="_blank">comparisons</a></p>
1717
<p>Try out other examples!</p>
1818
<ul>
@@ -38,6 +38,7 @@ <h1>smartscroll - Keep History</h1>
3838
</div>
3939
</div>
4040
<script type="text/javascript" src="../../bower_components/lethargy/lethargy.min.js"></script>
41+
<script type="text/javascript" src="../../smartscroll.js"></script>
4142
<script>
4243
$.smartscroll({
4344
keepHistory: true

examples/permalink/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="section" data-hash="a">
1313
<div>
1414
<h1>smartscroll - Permalink</h1>
15-
<p>A tiny (1046b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
15+
<p>A tiny (1048b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
1616
<p>See it on <a href="https://github.com/d4nyll/smartscroll" target="_blank">GitHub</a>, or see some <a href="http://blog.danyll.com/smartscroll-jquery-scrolljacking-plugin/" target="_blank">comparisons</a></p>
1717
<p>Try out other examples!</p>
1818
<ul>
@@ -43,6 +43,7 @@ <h1>smartscroll - Permalink</h1>
4343
</div>
4444
</div>
4545
<script type="text/javascript" src="../../bower_components/lethargy/lethargy.min.js"></script>
46+
<script type="text/javascript" src="../../smartscroll.js"></script>
4647
<script>
4748
$.smartscroll({});
4849
</script>

examples/responsive/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div class="header">
1212
<div>
1313
<h1>smartscroll - Responsive</h1>
14-
<p>A tiny (1050b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
14+
<p>A tiny (1048b minfied + gzipped) jQuery plugin for scrolljacking and auto-hashing</p>
1515
<p>See it on <a href="https://github.com/d4nyll/smartscroll" target="_blank">GitHub</a>, or see some <a href="http://blog.danyll.com/smartscroll-jquery-scrolljacking-plugin/" target="_blank">comparisons</a></p>
1616
<p>Try out other examples!</p>
1717
<ul>
@@ -73,6 +73,7 @@ <h1>Keep History</h1>
7373
</div>
7474
</div>
7575
</div>
76+
<script type="text/javascript" src="../../bower_components/lethargy/lethargy.min.js"></script>
7677
<script type="text/javascript" src="../../smartscroll.js"></script>
7778
<script>
7879
$.smartscroll({

smartscroll.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
keepHistory: false,
99
sectionWrapperSelector: ".section-wrapper",
1010
sectionClass: "section",
11-
animationSpeed: 300,
11+
animationSpeed: 500,
1212
headerHash: "header",
1313
breakpoint: null
1414
}
@@ -115,10 +115,10 @@
115115
var bindScroll = function () {
116116
$(window).bind('mousewheel DOMMouseScroll', function(e){
117117
if(Math.max(window.document.body.scrollTop, document.documentElement.scrollTop) >= $(options.sectionWrapperSelector + ':first').position().top) {
118+
var validScroll = lethargy.check(e);
119+
e.preventDefault()
120+
e.stopPropagation();
118121
if(!scrolling) {
119-
e.preventDefault()
120-
e.stopPropagation();
121-
var validScroll = lethargy.check(e);
122122
if (validScroll === 1) {
123123
scrollUp();
124124
} else if (validScroll === -1) {

smartscroll.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)