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

added hideOnStill functionality #32

Open
wants to merge 4 commits 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
13 changes: 13 additions & 0 deletions dist/jquery.scrollUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,21 @@

// Scroll function
scrollEvent = $(window).scroll(function () {
var scrollPos = $(window).scrollTop();
if ($(window).scrollTop() > scrollDis) {
if (!triggerVisible) {
$self[animIn](animSpeed);
triggerVisible = true;
}else{
if(o.hideWhenStill){
setTimeout(function(){
// If scollPos matches current scroll position after hesitation time, apply animOut.
if(scrollPos === $(window).scrollTop()){
$self[animOut](animSpeed);
triggerVisible = false;
}
}, o.hideHesitation);
}
}
} else {
if (triggerVisible) {
Expand Down Expand Up @@ -138,6 +149,8 @@
easingType: 'linear', // Scroll to top easing (see http://easings.net/)
animation: 'fade', // Fade, slide, none
animationSpeed: 200, // Animation in speed (ms)
hideWhenStill: false, // Hide element after scroll stops
hideHesitation: 2500, // Time to leave element visible after scroll stops
scrollTrigger: false, // Set a custom triggering element. Can be an HTML string or jQuery object
scrollTarget: false, // Set a custom target element for scrolling to. Can be element or number
scrollText: 'Scroll to top', // Text for element, can contain HTML
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.scrollUp.min.js

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

13 changes: 13 additions & 0 deletions src/jquery.scrollUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,21 @@

// Scroll function
scrollEvent = $(window).scroll(function () {
var scrollPos = $(window).scrollTop();
if ($(window).scrollTop() > scrollDis) {
if (!triggerVisible) {
$self[animIn](animSpeed);
triggerVisible = true;
}else{
if(o.hideWhenStill){
setTimeout(function(){
// If scollPos matches current scroll position after hesitation time, apply animOut.
if(scrollPos === $(window).scrollTop()){
$self[animOut](animSpeed);
triggerVisible = false;
}
}, o.hideHesitation);
}
}
} else {
if (triggerVisible) {
Expand Down Expand Up @@ -132,6 +143,8 @@
easingType: 'linear', // Scroll to top easing (see http://easings.net/)
animation: 'fade', // Fade, slide, none
animationSpeed: 200, // Animation in speed (ms)
hideWhenStill: false, // Hide element after scroll stops
hideHesitation: 2500, // Time to leave element visible after scroll stops
scrollTrigger: false, // Set a custom triggering element. Can be an HTML string or jQuery object
scrollTarget: false, // Set a custom target element for scrolling to. Can be element or number
scrollText: 'Scroll to top', // Text for element, can contain HTML
Expand Down