A simple Angular.js directive to create "Back to top" button when user reaches the end of the page.
You can see a working demo here.
Assuming that you already have Angular.js in your app, include angular-backtop.js and angular-backtop.css.
Add directive as your dependency:
var app = angular.module('app', ['angular.backtop']);
Create directive element somewhere inside of your tag:
<back-top></back-top>
... and thats all, you have a basic button, that will appear when you start scrolling the page. Click on it to be redirected to the top.
You can pass some more options to the directive.
- scroll-speed - Speed in miliseconds, default value is 600
- button-theme - Themes for button, there is bootstrap, dark & light. Default it light.
- button-text - Text, that will be displayed inside of a button. Default is Scroll top.
Example:
<back-top scroll-speed=600 button-theme="light" button-text="Take me back"></back-top>
npm install
grunt karma:unit