Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add safety check on scroll method #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jquery.fs.scroller.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Scroller v3.0.4 - 2014-04-08
* Scroller v3.0.4 - 2014-06-16
* A jQuery plugin for replacing default browser scrollbars. Part of the Formstone Library.
* http://formstone.it/scroller/
*
Expand Down
26 changes: 13 additions & 13 deletions jquery.fs.scroller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Scroller v3.0.4 - 2014-04-08
* Scroller v3.0.4 - 2014-06-16
* A jQuery plugin for replacing default browser scrollbars. Part of the Formstone Library.
* http://formstone.it/scroller/
*
Expand Down Expand Up @@ -77,22 +77,22 @@
scroll: function(pos, dur) {
return $(this).each(function(i) {
var data = $(this).data("scroller"),
duration = dur || options.duration;

if (typeof pos !== "number") {
var $el = $(pos);
if ($el.length > 0) {
var offset = $el.position();
if (data.horizontal) {
pos = offset.left + data.$content.scrollLeft();
duration = dur || options.duration;
if (data){
if (typeof pos !== "number") {
var $el = $(pos);
if ($el.length > 0) {
var offset = $el.position();
if (data.horizontal) {
pos = offset.left + data.$content.scrollLeft();
} else {
pos = offset.top + data.$content.scrollTop();
}
} else {
pos = offset.top + data.$content.scrollTop();
pos = data.$content.scrollTop();
}
} else {
pos = data.$content.scrollTop();
}
}

if (data.horizontal) {
data.$content.stop().animate({ scrollLeft: pos }, duration);
} else {
Expand Down
4 changes: 2 additions & 2 deletions jquery.fs.scroller.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions src/jquery.fs.scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,22 @@
scroll: function(pos, dur) {
return $(this).each(function(i) {
var data = $(this).data("scroller"),
duration = dur || options.duration;

if (typeof pos !== "number") {
var $el = $(pos);
if ($el.length > 0) {
var offset = $el.position();
if (data.horizontal) {
pos = offset.left + data.$content.scrollLeft();
duration = dur || options.duration;
if (data){
if (typeof pos !== "number") {
var $el = $(pos);
if ($el.length > 0) {
var offset = $el.position();
if (data.horizontal) {
pos = offset.left + data.$content.scrollLeft();
} else {
pos = offset.top + data.$content.scrollTop();
}
} else {
pos = offset.top + data.$content.scrollTop();
pos = data.$content.scrollTop();
}
} else {
pos = data.$content.scrollTop();
}
}

if (data.horizontal) {
data.$content.stop().animate({ scrollLeft: pos }, duration);
} else {
Expand Down