Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marchaos/toggle-switch
Mobile inspired toggle switch for modern browsers
https://github.com/marchaos/toggle-switch
apple control javascript switch toggle
Last synced: 6 days ago
JSON representation
Mobile inspired toggle switch for modern browsers
- Host: GitHub
- URL: https://github.com/marchaos/toggle-switch
- Owner: marchaos
- Created: 2012-12-29T21:08:25.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-12-21T08:53:26.000Z (almost 9 years ago)
- Last Synced: 2024-11-02T13:50:22.215Z (13 days ago)
- Topics: apple, control, javascript, switch, toggle
- Language: JavaScript
- Size: 70.3 KB
- Stars: 13
- Watchers: 5
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Toggle Switch
A lightweight, zero dependency, toggle switch for modern browsers. Inspired by mobile toggle switches.
* 2.5kB compressed JavaScript, 1kB compressed CSS
* Supports mobile devices (swipe and click)
* Supports desktop (drag and click)See http://marchaos.github.com/toggle-switch for a demo.
# Embedding
```html
```
# JavaScript API
```javascript
var switch = new ToggleSwitch(document.getElementById('cb'), 'ON', 'OFF');
// switch on
switch.on();
// switch off
switch.off();
// toggle on
switch.toggle();
// switch disable
switch.disable();
// switch enable
switch.enable();
alert("Switch is " + ((switch.isOn()) ? "on" : "off") + "!");
alert("Switch is " + ((switch.isDisabled()) ? "disabled" : "enabled") + "!");
```#Kudos
[Chris Brimmel's IOS 5 toggle switch images](http://dribbble.com/shots/216058-iOS-5-Toggle-Switches-iPhone-Retina)