Skip to content

Commit 6478c43

Browse files
committed
Add check for document.scrollingElement
* See https://dev.opera.com/articles/fixing-the-scrolltop-bug/
1 parent f2b800c commit 6478c43

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

jquery.smooth-scroll.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Smooth Scroll - v1.5.5 - 2015-02-19
2+
* jQuery Smooth Scroll - v1.5.6 - 2015-09-08
33
* https://github.com/kswedberg/jquery-smooth-scroll
44
* Copyright (c) 2015 Karl Swedberg
55
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
@@ -18,7 +18,7 @@
1818
}
1919
}(function ($) {
2020

21-
var version = '1.5.5',
21+
var version = '1.5.6',
2222
optionOverrides = {},
2323
defaults = {
2424
exclude: [],
@@ -58,9 +58,18 @@
5858
dir = opts.dir && opts.dir === 'left' ? 'scrollLeft' : 'scrollTop';
5959

6060
this.each(function() {
61-
62-
if (this === document || this === window) { return; }
6361
var el = $(this);
62+
63+
if (this === document || this === window) {
64+
return;
65+
}
66+
67+
if ( document.scrollingElement && (this === document.documentElement || this === document.body) ) {
68+
scrollable.push(document.scrollingElement);
69+
70+
return false;
71+
}
72+
6473
if ( el[dir]() > 0 ) {
6574
scrollable.push(this);
6675
} else {

jquery.smooth-scroll.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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-smooth-scroll",
33
"title": "jQuery Smooth Scroll",
4-
"version": "1.5.5",
4+
"version": "1.5.6",
55
"scripts": {},
66
"main": "jquery.smooth-scroll.js",
77
"author": {

src/jquery.smooth-scroll.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(function($) {
2-
var version = '1.5.5',
2+
var version = '1.5.6',
33
optionOverrides = {},
44
defaults = {
55
exclude: [],
@@ -39,9 +39,18 @@
3939
dir = opts.dir && opts.dir === 'left' ? 'scrollLeft' : 'scrollTop';
4040

4141
this.each(function() {
42-
43-
if (this === document || this === window) { return; }
4442
var el = $(this);
43+
44+
if (this === document || this === window) {
45+
return;
46+
}
47+
48+
if ( document.scrollingElement && (this === document.documentElement || this === document.body) ) {
49+
scrollable.push(document.scrollingElement);
50+
51+
return false;
52+
}
53+
4554
if ( el[dir]() > 0 ) {
4655
scrollable.push(this);
4756
} else {

0 commit comments

Comments
 (0)