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

grants-angular-off-canvas

v0.1.2

Published

Fork of angular-off-canvas. I needed strict di. I submitted a PR to angular-off-canvas.

Downloads

7

Readme

angular-off-canvas

Build Status

An off-canvas nav factory service for AngularJS that makes it easy to add off-canvas navs to your app. Plunker demo

Install

bower install angular-off-canvas

Usage

  1. Include the off-canvas.js script provided by this component into your app.
  2. Optional: Include the off-canvas.css style provided by this component into your html.
  3. Add cn.offCanvas as a module dependency to your app.

Typical Use

app.js

angular.module('myApp', ['cn.offCanvas']).

// let's make a nav called `myOffCanvas`
factory('myOffCanvas', function (cnOffCanvas) {
  return cnOffCanvas({
    controller: 'MyOffCanvasCtrl',
    controllerAs: 'offCanvas',
    templateUrl: 'my-off-canvas.html'
  });
}).

// typically you'll inject the offCanvas service into its own
// controller so that the nav can toggle itself
controller('MyOffCanvasCtrl', function (myOffCanvas) {
  this.toggle = myOffCanvas.toggle;
}).

my-off-canvas.html

<div class="off-canvas__nav">
  <h3>Hello {{name}}</h3>
  <p><a href ng-click="offCanvas.toggle()">Close Me</a></p>
</div>

index.html

<div ng-app="myApp" ng-controller="MyCtrl as ctrl">
  <a href ng-click="ctrl.toggle()">Show the modal</a>
</div>

Cleaning up

If you add any listeners within the nav's controller that are outside the nav's scope, you should remove them with $scope.$on('$destroy', fn () { ... }) to avoid creating a memory leak.

Inline Options

Note: The best practice is to use a separate file for the template and a separate declaration for the controller, but inlining these options might be more pragmatic for cases where the template or controller is just a couple lines.

angular.module('myApp', ['cn.offCanvas']).

// let's make a nav called myOffCanvas
factory('myOffCanvas', function (btfModal) {
  return btfModal({
    controller: function () {
      this.name = 'World';
    },
    controllerAs: 'ctrl',
    template: '<div class="off-canvas__nav">Hello {{ctrl.name}}</div>'
  });
}).

controller('MyCtrl', function (myOffCanvas) {
  this.toggle = myOffCanvas.toggle;
});
<div ng-app="myApp" ng-controller="MyCtrl">
  <a href ng-click="ctrl.toggle()">Toggle the nav</a>
</div>

API

cnOffCanvas

The nav factory. Takes a configuration object as a parameter:

var navService = cnOffCanvas({
  /* options */
})

And returns a navService object that you can use to toggle the nav (described below).

The config object must either have a template or a templateUrl option.

These options work just like the route configuration in Angular's $routeProvider.

config.template

string: HTML string of the template to be used for this modal. Unless the template is very simple, you should probably use config.templateUrl instead.

config.templateUrl

string (recommended): URL to the HTML template to be used for this modal.

config.controller

string|function (optional): The name of a controller or a controller function.

config.controllerAs

string (optional, recommended): Makes the controller available on the scope of the modal as the given name.

config.container

DOM Node (optional): DOM node to prepend. Defaults to document.body.

config.containerClass

string (optional): HTML class to add to the container. Defaults to is-off-canvas-opened.

navService

A navService has only one method: toggle which enable us to show/hide the nav.

navService.toggle

Add or remove a class to open/hide the nav with CSS.

Contributing

Please see the contributing guidelines

Tests

You can run the tests with karma:

karma start

License

MIT