Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)
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…

762 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

18 Experts available now in Live!

Get 1:1 Help Now