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

angular-scroll-animate

v0.9.9

Published

An Angular.js directive which allows you to perform any javascript actions (in the controller, or on the element) when an element is scrolled into, or out of, the users viewport, without any other dependencies.

Downloads

1,046

Readme

Angular Scroll Animate

An Angular.js directive which allows you to perform any javascript actions (in the controller, or on the element) when an element is scrolled into or out of, the users viewport, without requiring any other dependencies.

Build Status

Motivation

ngAnimate is great if you want animations based on showing or hiding elements based on some behaviour, but what if you want to trigger behaviour when an element is scrolled into, or out of the user's view?

The goal of this directive is to be small and focused around behaviour that changes when scrolled in and out of view, without requiring jQuery. You can add / remove CSS classes in the callbacks, or execute any arbitrary javascript you want such as pre-loading of data, images or anything else.

Demo

Demo

NG Docs

link

Inspiration

Installation

  1. Install the plugin into your Angular.js project, manually or via

bower install angular-scroll-animate --save

  1. Include angular-scroll-animate.js in your app:

<script src="bower_components/angular-scroll-animate/dist/angular-scroll-animate.js"></script>

  1. Add angular-scroll-animate as a new module dependency in your angular app.

var myapp = angular.module('myapp', ['angular-scroll-animate']);

  1. Ensure you have a CSS class to mask the visibility of an element eg.
.not-visible {
  visibility: hidden;
}

Add this to the elements class if you want it to be hidden initially when out of a user's view, and remove it on the animateElementIn callback and add it back on animateElementOut callback.

Example markup:

  <!-- angular view -->
  <div ng-repeat="car in cars"
    when-visible="animateElementIn"
    when-not-visible="animateElementOut" class="hidden car">
  ...
  </div>
  // controller
  $scope.cars = [ ... ];

  $scope.animateElementIn = function($el) {
  $el.removeClass('hidden');
  $el.addClass('animated fadeInUp'); // this example leverages animate.css classes
};

$scope.animateElementOut = function($el) {
  $el.addClass('hidden');
  $el.removeClass('animated fadeInUp'); // this example leverages animate.css classes
};

Notes

  • when-visible($el): [required] function (executed in the controller scope) which is called when the element is scrolled into view.

  • when-not-visible($el): [optional] function (executed in the controller scope) which is called when the element is moved out of view via scrolling.

  • delay-percent="0.50": [optional] decimal value which represents how much of the element should be in the users viewport before triggering the bound callback. 0.25 is set as a default, a lower value will make it more eager, a higher value will make it lazier.

  • bind-scroll-to=".classname": [optional] If you are using overflow: auto in a container and the elements are not appearing when they should set replace classname with the class you have applied overflow: auto to.

  • To ensure fast CSS3 transition rules are used for animations, I recommend either velocity.js or animate.css which come with many pre-built and tested CSS animation classes.

  • Default event bindings are on scroll resize and orientationchange of the document element this directive is loaded in.

Running Locally

  1. Checkout git repository locally: git clone [email protected]:rpocklin/angular-scroll-animate.git
  2. npm install
  3. bower install
  4. grunt serve
  5. View http://localhost:9000/example/ in your browser to see the example.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Beautify (grunt beautify)
  4. Ensure it passes code-checks / tests (grunt)
  5. Commit your changes (git commit -am 'Added some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create a new Pull Request

History

  • 0.9.9 Changed .hidden class in example to .not-visible to avoid CSS clashes.
  • 0.9.8 Added override attribute of bind-scroll-to to bind scroll events to custom parents - see #3).
  • 0.9.8 Optimised reflow / repaints to use requestAnimationFrame for performance reasons.
  • 0.9.4 Re-fixed when-not-visible so it is truely optional (thanks @jagged3dge)
  • 0.9.3 Changed Number.isNaN to use !angular.isNumber instead (original function not available in all browsers yet) (see #2).
  • 0.9.2 Fixed error when not defining when-not-visible attributes and updated NG Docs (see #1).
  • 0.9.1 Removed (incorrectly) namespaced events, not supported in JQ-Lite.
  • 0.9.0 Fixed event unbinding when removing bound elements from the DOM.
  • 0.8.0 Initial release

TODO

  • Get more feedback and feedback on different browsers (especially mobile / tablets).
  • Add debounce timing
  • Consider using events instead?
  • Add some tests

License

Released under the MIT License. See the LICENSE file for further details.