Giter Site home page Giter Site logo

fekrh / material-scrolltop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bartholomej/material-scrolltop

0.0 2.0 0.0 706 KB

Lightweight, Material Design inspired plugin for scrolling on top of the html page (with jQuery)

Home Page: http://bartholomej.github.io/material-scrolltop/

License: MIT License

CSS 68.59% JavaScript 31.41%

material-scrolltop's Introduction

Join the chat at https://gitter.im/material-scrolltop/Lobby

Material ScrollTop Button

Lightweight, Material Design inspired button for scroll-to-top of the page (jQuery plugin).

Just hit the button to smoothly scroll back to the top of the page. Here's the demo.

  • Lightweight
  • Material Design inspired
  • With ripple effect
  • Smoothly animated
  • Customizable
  • With some useful options...
  • CSS3 (Sass) + jQuery

Demo animation

Demo (example)

Watch this: http://bartholomej.github.io/material-scrolltop/

Install

Via bower:

bower install material-scrolltop

Manual install (download)

If you want the latest stable version, get the latest release from the releases page.

Usage

Include the files as shown in the code snippets below and you're done.

NOTE: The only dependency for this plugin to work is jQuery library (don't forget!)

In your <head> add:

<!-- Material ScrollTop stylesheet -->
<link rel="stylesheet" href="css/material-scrolltop.css">

Then, before your closing </body> tag add:

<!-- material-scrolltop button -->
<button class="material-scrolltop" type="button"></button>

<!-- material-scrolltop plugin -->
<script src="js/material-scrolltop.js"></script>

<!-- Initialize material-scrolltop with (minimal) -->
<script>
    $('body').materialScrollTop();
</script>

Settings

Option Type Default Description
revealElement string body Reveal button when scrolling over specific element
revealPosition string top Element position for reveal button ('top' or 'bottom')
padding number 0 Adjusts little ups and downs in scrolling (can be negative number)
duration number 600 Determining how long the animation will run
easing string 'swing' Indicating which easing function to use for the transition animate()
onScrollEnd Function() false A function to call once the animation is complete

Example

$('body').materialScrollTop({   // Scroll to the top of <body> element ...
    padding: 100,               // ... and add padding 100px
    revealElement: 'header',    // Reveal button when scrolling over <header> ...
    revealPosition: 'bottom',   // ... and do it at the end of </header> element
    duration: 600,              // Animation will run 600 ms
    easing: 'swing',            // Do it with swing animation
    onScrollEnd: function() {   // Give me some log when animation ends
        console.log('This is the end, my only friend, the end...');
    }
});

Customization

Colors, sizes and stuff

Using SASS (this file), you can simply edit default styles, colors, position and customize plugin to fit your needs. ๐Ÿ‘ (Or just edit directly css stylesheet)

Icons

SVG

You can change svg icon in src/icons/ directory.

Custom text or sign

  1. Turn off svg icon as sass variable: $mst-icon: false
  2. Build your new stylesheet (now without svg icon)
  3. Put your new sign or text inside html <span> element like this:
<button class="material-scrolltop" type="button">
        <span>โ†‘</span>
</button>

Dependencies

jQuery 1.7+

License

Copyright ยฉ 2015 Lukas Bartak

Proudly powered by nature, wind, tea and beer ;)

All contents are licensed under the MIT license.

material-scrolltop's People

Contributors

bartholomej avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.