npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-augment-native-scroll

v0.15.0

Published

Augmenting native scroll with higher functionality

Downloads

7

Readme

ng Augment Native scroll npm version Bower version

This module aims to augment native scroll to provide few neat features. The features available as directives, are applied intelligently, based on the user device. Touch or non-touch. This is a angular (v1.x) port of the original experiments with augment native scroll.

###Connect Scrolls It can connect two or more scrollable areas so that they all scroll as one. Wrap each scrollable area with scrollArea directive, then wrap them all with connectScrolls directive. connectScrolls connects scrollable areas within scrollArea. For non-touch devices it can also apply kinetic scrolling.

Demo | Usage

###Kinetic Scroll It will apply touch-device-like smooth and kinetic scroll to native scroll. You can (mouse) click-hold to drag the scroll and release-flick to auto-scroll just like a kinetic scroll on touch devices. Just wrap the scrollable area with kineticScroll directive.

Demo | Usage

NOTE: Kinetic scroll with mouse events will be applied to non-touch devices only. It will NOT be applied on touch devices.

Installation and usage

###Via yarn or npm:

# yarn (recommended)
$ yarn add ng-augment-native-scroll

#npm
$ npm install ng-augment-native-scroll --save

Then use it as:

var angular = require('angular');
angular.module('mainApp', [ require('ng-augment-native-scroll') ]);

###Via bower:

$ bower install ng-augment-native-scroll --save

Then use it as:

var angular = require('angular');
var ngAugmentNativeScroll = require('./bower_components/ng-augment-native-scroll/src');

angular.module('mainApp', ['ng-augment-native-scroll']);

You can also include it in the old fashion way as:

<script src="/bower_components/ng-augment-native-scroll/dist/ngAugmentNativeScroll.js"></script>
<!-- or -->
<script src="/bower_components/ng-augment-native-scroll/dist/ngAugmentNativeScroll.min.js"></script>

###Direct use: Download the files as zip or tar.gz. Include it in your HTML file and use it in your script file as shown below:

<!-- template.html -->
<script src="<path-to-folder>/dist/ngAugmentNativeScroll.js" charset="utf-8"></script>
// main.js
angular.module('mainApp', ['ng-augment-native-scroll']);

connectScroll and scrollArea directive usage

These directives can be used like the example below:

<connect-scrolls options="options">
    <scroll-area>
        <ul id="list">
            <li ng-repeat="item in data.list">{{ item }}</li>
        </ul>
    </scroll-area>
    <scroll-area>
        <table id="table">
            <tbody>
                <tr ng-repeat="row in data.table track by $index">
                    <td ng-repeat="cell in row track by $index">{{ cell }}</td>
                </tr>
            </tbody>
        </table>
    </scroll-area>
</connect-scrolls>

scrollArea requires connectScroll and connectScroll expects scrollArea to define the scrollable areas to be connected. Neither can be used alone. You can use multiple connect-scrolls within the same scope. You can even nest one within other. But do not overlap one another, it's not supported yet.

kineticScroll directive usage

This directive can be used like the example below:

<kinetic-scroll options="options">
    <table id="table">
        <tbody>
            <tr ng-repeat="row in data.table track by $index">
                <td ng-repeat="cell in row track by $index">{{ cell }}</td>
            </tr>
        </tbody>
    </table>
</kinetic-scroll>

kineticScroll expects its first child to be a scrollable area. It's better to wrap just the scrollable item with kineticScroll. You can use multiple connect-scrolls within the same scope. You can even nest one within other.

Configurable options

Option | Description | Type | Default --- | :--- | :--- | :--- name | Give it a name, a unique name. The directives will be exposing the helper methods to the $parent scope on this namespace. Provide a unique name when using multiple or nested instances. | String | NA enableKinetics | On touch devices kinetics won't be applied. Apply touch-device-like smooth and kinetic scroll to native scroll. You can (mouse) click-hold to drag the scroll and release-flick to auto-scroll just like a kinetic scroll on touch devices. | Boolean | true movingAverage | The moving average filter protects the kinetic scroll going to a frenzy state. A lower value will have a slow and smooth kinetic scroll | Number | 0.1 preventDefaultException | Mouse events for kinetic scrolling is prevented from executing default action, i:ee.preventDefault() is called internally. This can make elements non-responsive. For e.g: select wont open. You can provide tagName, class or id that when matched wont call preventDefault. By default input, textarea, button and select are exempted. | Object | Look here

Exposed methods to $parent

Both directive connectScrolls and kineticScroll will expose couple of methods to it's parent scope. With the exposed methods we can control the scroll from $parent scope; for e.g. scroll to start or end. The exposed methods will be available on the namespace ~~augNs~~ as provided in in the options. For e.g. let's assume the option is { name: 'myAugNs' } then the exposed methods will be available on $scope.myAugNs Here are the list of exposed methods:

Name | Description --- | :--- scrollToStart | Scrolls all scroll to start, i:e scrollLeft and scrollTop are set to 0 scrollToStartLeft | Scrolls all scrollLeft to start scrollToStartTop | Scrolls all scrollTop to start scrollToEnd | Scrolls all scroll to end or max scroll, i:e scrollLeft and scrollTop are set to possible max scroll value scrollToEndLeft | Scrolls all scrollLeft to end or max scroll left value scrollToEndTop | Scrolls all scrollTop to end or max scroll top value scrollToPosition | Scrolls to the positions provided as arguments. $scope.augNs.scrollToPosition({Number} left, {Number} top) scrollByValue | Scroll to new positions by adding the arguments provided to current positions. $scope.augNs.scrollByValue({Number} left, {Number} top)

Here is an example of how it can be used on the $parent scope:

// connect-scroll options
$scope.options = {
    name: 'myAugNs'
}

// reset scroll after fetching new data
DataService.fetchUserList()
    .then(function (data) {
        $scope.userList = data;
        $scope.myAugNs.scrollToStart();
    })

TODO

Testing and code-coverage.

#Future

  • Implement pull-down-to functionality - refresh or load previous page to name a few
  • Implement pull-up-to functionality - load next page may be