Coder Social home page Coder Social logo

circular-slider's Introduction

circular-slider - A jQuery Plugin

Circular slider is a jQuery plugin which helps to slide range of values and images. It supports half(top/bottom/up/down) and full circle shapes. #####Demo Page

Getting Started

Download the latest code

Fork this repository or download js/css files from dist directory.

Including it on your page

Include jQuery and this plugin on a page.

<link rel="stylesheet" href="circular-slider.min.css" />
<script src="jquery.js"></script>
<script src="circular-slider.min.js"></script>

Basic Usage

<div id="slider"></div>
var slider = $('#slider').CircularSlider();

Properties

radius

radius of the circle in px.

innerCircleRatio

ratio of inner circle area(used to display current sliding value). ratio can be in the range between 0.10 and 0.90 (open interval).

min

min value of the slider.

max

max value of the slider.

value

Initial value of the slider.

clockwise

direction of the sliding value.

labelSuffix

label to be used as suffix along with current sliding value.

labelPrefix

label to be used as prefix along with current sliding value.

shape

shape of the slider. Supported shapes are:

  1. 'circle' (default)
  2. 'half circle'
  3. 'half circle left'
  4. 'half circle right'
  5. 'half circle bottom'

touch

touch support. (default: true)

selectable

text selection enabled or not. (default: false)

Callback

function slide(ui, value)

slide callback is triggered whenever there is a change in sliding value.

Parameters:

ui -  dom element
value - Current sliding value

function formLabel(value, prefix, suffix)

formLabel callback is triggered with current sliding value, prefix and suffix. If it is defined, it will be used as a source for inner circle area.

Parameters:

value - Current sliding value
prefix - prefix configured
suffix - suffix configured

Default Settings

Slider with default values

var slider = $('#slider').CircularSlider({
    radius: 75,
    innerCircleRatio: '0.5',
    min: 0,
    max: 359,
    value: 0,
    clockwise: true,
    labelSuffix: "",
    labelPrefix: "",
    shape: "Circle",
    touch: true,
    selectable: false,
    slide: function(ui, value) {},
    formLabel: undefined
});

CSS classes

Use the below css classes for customization

.jcs-panel - circular slider panel

.jcs - Slider area

.jcs-value - Inner circle area

.jcs-indicator - Slide indicator ball

Advanced Usage (image carousel)

var imageSlider = $('#slider-customized').CircularSlider({
	min : 0,
	max: 359,
	radius: 100,
	innerCircleRatio : .7,
	formLabel : function(value, prefix, suffix) {
		return '<img src="assets/images/baby'+ parseInt(value / 26)+'.png"></img>';
	},
	slide : function(ui, value) {
		var colors = ['deeppink', 'seagreen', 'deepskyblue', 'coral', 'cadetblue', 'olive', 'chocolate',
        	'yellowgreen', 'cornflowerblue', 'slategrey', 'salmon', 'brown', 'darkgoldenrod', 'dimgrey'];
		var color = colors[parseInt(value / 26)];
		ui.find('.jcs').css({'border-color' : color });
		ui.find('.jcs-indicator').css({'background' : color });
	}
});

License

This plugin is licensed under the MIT license.

Copyright (c) 2014 Prince John Wesley

circular-slider's People

Contributors

princejwesley avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.