Solved

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

Posted on 2016-10-27
2
82 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
Rob 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article discusses how to implement server side field validation and display customized error messages to the client.
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)

751 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