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-slides

v1.1.0

Published

AngularJS directive for vertical, fullscreen, slide-based web pages.

Downloads

9

Readme

angular-slides

AngularJS directive for vertical, fullscreen, slide-based web pages.

Overview

The goal of this project is to easily allow layouts with the following features:

  • the page is divided into a vertical sequence of slides
  • each slide is fullscreen, i.e. it spans the whole viewport
  • users can't (directly) scroll: up and down arrow key are used to change slide (with scrolling performed programmatically in JavaScript)
  • indvidual slides can be linked

Also, events are fired to signal slide changes, which is useful to hide, reveal and animate stuff.

See it in action!

Getting started

Adding angular-slides to your project

Use npm:

$ npm install angular-slides

or Bower:

$ bower install msl-slides

Then, inside your HTML page:

<!-- AngularJS is the only required dependency -->
<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-slides/dist/msl_slides.js"></script>
<script src="your_code.js"></script>

Note: If you're using Bower, just replace node_modules with bower_components and angular-slides with msl-slides.

Note: The demo folder of this repository contains a working example. Another useful example is this project's website.

Using the mslSlides directive

Basics

<msl-slides>
  <div>First slide</div>
  <div>Second slide</div>
  <div>Third slide</div>
</msl-slides>

Note: CSS styling is up to you. The only style added by the mslSlides directive is 100vw width and 100vh height to each slide.

Note: Remember to load the msl.slides module into your AngularJS app, e.g.:

var myApp = angular.module('myApp', ['msl.slides']);

Links

<msl-slides>
  <div>
    <p>
      First slide
    </p>
    <p>
      Go to <a href="#?slide_number=1">next slide</a>
    </p>
  </div>
  <div>
    <p>
      Second slide
    </p>
  </div>
</msl-slides>

Events

<body ng-controller="MyCtrl">
  <msl-slides>
    <div>
      <p>
        First slide
      </p>
    </div>
    <div>
      <p>
        Second slide
      </p>
    </div>
  </msl-slides>
</body>
angular.module('myApp').controller('MyCtrl', function ($scope) {
  $scope.$on(
    'msl_slides_slide_change_start',
    function (event, old_slide_number, new_slide_number) {
      console.log(
        'Changing from ' + old_slide_number + ' to ' + new_slide_number
      );
    }
  );
  $scope.$on(
    'msl_slides_slide_change_success',
    function (event, old_slide_number, new_slide_number) {
      console.log(
        'Changed from ' + old_slide_number + ' to ' + new_slide_number
      );
    }
  );
});

API

If you're not happy with the previous examples, here is a bunch of detailed informations that will hold true (until breaking changes):

  • the mslSlides directive is hosted inside an AngularJS module called msl.slides
  • slides must be put inside the <msl-slides> element
  • a slide can be any HTML element (although inline elements don't make sense)
  • slides are numbered starting from 0
  • the mslSlides directive applies 100vw width and 100vh height to each slide
  • slide change is performed with up and down arrow keys
  • a msl_slides_slide_change_start AngularJS event is emitted when a slide change starts
  • a msl_slides_slide_change_success AngularJS event is emitted when a slide change is successfully completed
  • msl_slides_slide_change_start and msl_slides_slide_change_success handlers receive the "previous" and the "next" slide numbers (i.e. before and after the slide change) as second and third argument, e.g. function myHandler(event, old_slide, new_slide) { ... }
  • the slide_number query parameter in the address bar is kept in sync with the current slide number (synchronization happens when the animation completes)
  • thus, slide changes can be driven by links too

All other behaviors are to be intended as implementation-specific and should not be depended on.

For contributors

Source code is divided into many files inside the src directory. Here is a short description of these files' responsibilities:

  • src/module.js: provides the module that will host all the other components
  • src/directive/slides.js: defines the msl-slides directive
  • src/service/scroll_detector.js: handles wheel and keydown events in order to prevent regular scrolling and detect the user's will to scroll through up and down arrow keys
  • src/service/scroller.js: implements a sort of animated scrolling
  • src/service/config.js: just a couple of values that control the animated scrolling
  • src/service/location.js: sets and gets the slide number from $location
  • src/service/viewport.js: converts slide numbers into pixel offsets

Development tasks are handled with Grunt:

  • grunt test: run tests
  • grunt build: concat + minify (output inside the dist folder)

Development dependencies are handled with npm.