Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to make floating back to top button not float over footer

Posted on 2016-10-27
2
Medium Priority
?
129 Views
Last Modified: 2016-11-17
I have created this jsfiddle with a floating back to to top button.
At the bottom of the page is a footer with 5 headings.
I want to be able to make the button be in a fixed position until reaching footer after which it goes up.
I am trying to imitate the functionality of back to top button at http://www.sony.com/all-electronics
I am terrible at jquery and javascript so please don't change the jquery already present in the jsfiddle
Rather add more below to make it do what I want.
Any help much appreciated.
Thanks in advance.
https://jsfiddle.net/h5Lt2dv3/
0
Comment
Question by:Usman Sikander
2 Comments
 
LVL 43

Accepted Solution

by:
Rob earned 2000 total points (awarded by participants)
ID: 41865570
I've updated the fiddle: https://jsfiddle.net/voz8p8w6/1/

you just need to detect when the footer element comes into view and make the floating "UP" fixed

Added to your backToTop function
var _height = scrollTop + window.innerHeight;
            if (_height > $('footer').offset().top) {
            	$('#back-to-top').addClass('fixed');
            }
            else {
            $('#back-to-top').removeClass('fixed');
            }

Open in new window

CSS
#back-to-top.fixed {
  position: relative;
  float: right;
}

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question