Skip to content
Open
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
12 changes: 7 additions & 5 deletions jquery.scrollIntoView.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@
// it wiggles?
(pEl.scrollTop != ((pEl.scrollTop += 1) == null || pEl.scrollTop) && (pEl.scrollTop -= 1) != null) ||
(pEl.scrollTop != ((pEl.scrollTop -= 1) == null || pEl.scrollTop) && (pEl.scrollTop += 1) != null)) {
if (elY <= pY) scrollTo(pEl, elY); // scroll up
if ((opts.alignWithTop && (elY + elH) > (pY + pH)) || elY <= pY) scrollTo(pEl, elY); // scroll up
else if ((elY + elH) > (pY + pH)) scrollTo(pEl, elY + elH - pH); // scroll down
else scrollTo(pEl, undefined) // no scroll
return;
Expand All@@ -66,9 +66,9 @@
if (scrollTo === undefined) {
if ($.isFunction(opts.complete)) opts.complete.call(el);
} else if (opts.smooth) {
$(el).stop().animate({ scrollTop: scrollTo }, opts);
$(el).stop().animate({ scrollTop: scrollTo + opts.offset }, opts);
} else {
el.scrollTop = scrollTo;
el.scrollTop = scrollTo + opts.offset;
if ($.isFunction(opts.complete)) opts.complete.call(el);
}
}
Expand All@@ -83,7 +83,9 @@
// otherwise jQuery will default to use 'swing'
complete: $.noop(),
step: null,
specialEasing: {} // cannot be null in jQuery 1.8.3
specialEasing: {}, // cannot be null in jQuery 1.8.3
alignWithTop: false,
offset: 0
};

/*
Expand DownExpand Up@@ -134,4 +136,4 @@
return $([]);
}

})(jQuery);
})(jQuery);