Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/toddmotto/lunar

SVG class module for has/add/remove/toggleClass
https://github.com/toddmotto/lunar

Last synced: 12 days ago
JSON representation

SVG class module for has/add/remove/toggleClass

Awesome Lists containing this project

README

        

# lunar.js [![Build Status](https://travis-ci.org/toddmotto/lunar.svg)](https://travis-ci.org/toddmotto/lunar)

Lunar is a 0.7KB standalone SVG DOM class manipulation module that provides a wrapper for `addClass`, `hasClass`, `removeClass` and `toggleClass` methods. Lunar will work in all browsers that can natively run inline SVG (IE9+).

```html

// query SVG DOM
var svg = document.querySelector('.myClass');

// hasClass() returns boolean on class existence
lunar.hasClass(svg, 'className');

// addClass() adds class
lunar.addClass(svg, 'className');

// removeClass() removes class
lunar.removeClass(svg, 'className');

// toggleClass() toggles class
lunar.toggleClass(svg, 'className');

```

## Installing with Bower
Use the repository hook:

```
bower install https://github.com/toddmotto/lunar.git
```

## Manual installation
Ensure you're using the files from the `dist` directory (contains compiled production-ready code). Ensure you place the script before the closing `



var svg = document.querySelector('.myClass');
lunar.addClass(svg, 'mySVGClass');