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
22 changes: 14 additions & 8 deletions src/jquery.scrollUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$self.attr('title', o.scrollTitle);
}

$self.appendTo('body');
$self.appendTo(document.body);

// If not using an image display text
if (!(o.scrollImg || o.scrollTrigger)) {
Expand Down Expand Up @@ -89,8 +89,8 @@
}

// Scroll function
scrollEvent = $(window).scroll(function () {
if ($(window).scrollTop() > scrollDis) {
scrollEvent = $(o.scrollElement).scroll(function () {
if ($(o.scrollElement).scrollTop() > scrollDis) {
if (!triggerVisible) {
$self[animIn](animSpeed);
triggerVisible = true;
Expand All @@ -117,7 +117,12 @@
$self.click(function (e) {
e.preventDefault();

$('html, body').animate({
var ele = o.scrollElement;
if (ele === window)
ele = 'html, body';


$(ele).animate({
scrollTop: scrollTarget
}, o.scrollSpeed, o.easingType);
});
Expand All @@ -138,7 +143,8 @@
scrollTitle: false, // Set a custom <a> title if required. Defaults to scrollText
scrollImg: false, // Set true to use image
activeOverlay: false, // Set CSS color to display scrollUp active point, e.g '#00FFFF'
zIndex: 2147483647 // Z-Index for the overlay
zIndex: 2147483647, // Z-Index for the overlay
scrollElement: window
};

// Destroy scrollUp plugin and clean all modifications to the DOM
Expand All @@ -149,11 +155,11 @@

// If 1.7 or above use the new .off()
if ($.fn.jquery.split('.')[1] >= 7) {
$(window).off('scroll', scrollEvent);
$($.fn.scrollUp.settings.scrollElement).off('scroll', scrollEvent);

// Else use the old .unbind()
// Else use the old .unbind()
} else {
$(window).unbind('scroll', scrollEvent);
$($.fn.scrollUp.settings.scrollElement).unbind('scroll', scrollEvent);
}
};

Expand Down