Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/toddmotto/lunar
- Owner: toddmotto
- License: other
- Created: 2014-03-17T21:47:36.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-04-26T10:46:37.000Z (over 3 years ago)
- Last Synced: 2024-10-11T08:10:42.116Z (29 days ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 78
- Watchers: 11
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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');