GithubHelp home page GithubHelp logo

shengta / angular-scroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gavr-pavel/angular-scroll

0.0 2.0 0.0 67 KB

Scrolling the Angular way

Home Page: https://gavr-pavel.github.io/angular-scroll/demo.html

License: MIT License

HTML 91.80% JavaScript 8.20%

angular-scroll's Introduction

angular-scroll

Scrolling the Angular way.

The only dependency is Angular.

Usage

First, you have to include the module in your app:

var app = angular.module('YourModule', ['scroll']);
scroll-root and scroll-item directives
<!--
scroll-root attribute tells that element is scrollable;
    the scrollTo method is added to the scope.
scroll-item="someId" attribute tells that scrollable element
    can be scrolled to it's position by calling scrollTo('someId').
-->
<div class="scrollable" scroll-root>
    <div scroll-item="first_block">
        ...
        <button ng-click="scrollTo('second_block')">To the next block!</button>
    </div>
    ...
    <div scroll-item="second_block">
        ...
        <button ng-click="scrollTo('one_more_block')">To the next block!</button>
    </div>
    <div scroll-item="one_more_block">
        ...
        <button ng-click="scrollTo('first_block')">Back to start</button>
    </div>
</div>
scroll service
scroll({
    root: someElement,                // Element to be scrolled
    target: someInnerElement,         // Element inside the scrollable element
    duration: 700,                    // Animation duration in ms (default is 600)
    callback: function () {/* ... */} // The callback is called
                                      //     after the animation has been ended
});


// OR


scroll(someElement)
    .to(someInnerElement)
    .in(700)
    .then(function () {/* ... */});

// Duration and callback arguments are optional
//     so you can omit them:
scroll(someElement).to(someInnerElement);

Browser support

angular-scroll uses requestAnimationFrame, so if you want it working in old browsers you should use a polyfill. I'd recommend that one.

angular-scroll's People

Contributors

gavr-pavel avatar theland 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.