Solved

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

Posted on 2016-10-27
2
36 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 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

813 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now