Skip to content

Commit

Permalink
- add ldslider and deprecate ldSlider.
Browse files Browse the repository at this point in the history
  • Loading branch information
zbryikt committed Jun 2, 2021
1 parent 783b268 commit 85a4860
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## v2.0.4

- add `ldslider` and deprecate `ldSlider`.


## v2.0.3

- use `number ~ number` instead of `number to number` for input value.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Slider Library in Vanilla JS. Support exponential scale.
## Usage


1. download and include ldSlider [JS](https://github.com/loadingio/ldSlider/releases/latest/download/ldrs.min.js) / [CSS](https://github.com/loadingio/ldSlider/releases/latest/download/ldrs.min.css):
1. download and include ldSlider [JS](https://github.com/loadingio/ldslider/releases/latest/download/ldrs.min.js) / [CSS](https://github.com/loadingio/ldslider/releases/latest/download/ldrs.min.css):

<link rel="stylesheet" type="text/css" href="ldrs.css"/>
<script type="text/javascript" src="ldrs.js"></script>
Expand All @@ -17,20 +17,20 @@ you an use a CDN, such as, from jsDelivr:
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/loadingio/[email protected]/dist/ldrs.min.js"/>


2. create a new ldSlider instance for using ldSlider's API:
2. create a new ldslider instance for using ldSlider's API:

ldrs = new ldSlider(configs);
ldrs = new ldslider(configs);
ldrs.set(value);

Example:

<div class="ldrs"></div>
<script> ldrs = new ldSlider({root: document.querySelector('.ldrs')}); </script>
<script> ldrs = new ldslider({root: document.querySelector('.ldrs')}); </script>

You can also use an input box to initialize ldSlider:
You can also use an input box to initialize ldslider:

<input class="ldrs" data-class="form-control">
<script> ldrs = new ldSlider({root: document.querySelector('.ldrs')}); </script>
<script> ldrs = new ldslider({root: document.querySelector('.ldrs')}); </script>

In this case, a new `div` will be created and inserted before the `input` element, inherits all classes of the `input` element. The `input` element's type will be set to `hidden`.

Expand Down Expand Up @@ -94,7 +94,7 @@ Some quick and useful tweaks:

## Restyling with CSS Variable

Default colorschema of ldSlider can be changed with CSS variables by adding `tone` class along with `ldrs` class:
Default colorschema of ldslider can be changed with CSS variables by adding `tone` class along with `ldrs` class:

<div class="ldrs tone"> ... </div>

Expand Down
11 changes: 8 additions & 3 deletions dist/ldrs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var ldSlider;
ldSlider = function(opt){
var ldslider;
ldslider = function(opt){
var root, i$, to$, i, that, handle, el, mouse, this$ = this;
opt == null && (opt = {});
this.evtHandler = {};
Expand Down Expand Up @@ -105,7 +105,7 @@ ldSlider = function(opt){
this.prepare();
return this;
};
ldSlider.prototype = import$(Object.create(Object.prototype), {
ldslider.prototype = import$(Object.create(Object.prototype), {
on: function(n, cb){
var ref$;
return ((ref$ = this.evtHandler)[n] || (ref$[n] = [])).push(cb);
Expand Down Expand Up @@ -321,6 +321,11 @@ ldSlider.prototype = import$(Object.create(Object.prototype), {
}
}
});
if (typeof module != 'undefined' && module !== null) {
module.exports = ldslider;
} else if (typeof window != 'undefined' && window !== null) {
window.ldSlider = window.ldslider = ldslider;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
Expand Down
2 changes: 1 addition & 1 deletion dist/ldrs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "ldslider",
"license": "MIT",
"description": "Slider Library in Vanilla JS",
"version": "2.0.3",
"version": "2.0.4",
"files": [
"dist/**/*"
],
Expand Down
7 changes: 5 additions & 2 deletions src/ldrs.ls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ldSlider = (opt={}) ->
ldslider = (opt={}) ->
@ <<< evt-handler: {}, opt: {min: 0, max: 100, from: 0, to: 0, step: 1} <<< opt
@val = {to: 0, from: 0}
@root = root = if typeof(opt.root) == \string => document.querySelector(opt.root) else opt.root
Expand Down Expand Up @@ -82,7 +82,7 @@ ldSlider = (opt={}) ->
@prepare!
@

ldSlider.prototype = Object.create(Object.prototype) <<< do
ldslider.prototype = Object.create(Object.prototype) <<< do
on: (n, cb) -> @evt-handler.[][n].push cb
fire: (n, ...v) -> for cb in (@evt-handler[n] or []) => cb.apply @, v
update: -> @set @val
Expand Down Expand Up @@ -193,3 +193,6 @@ ldSlider.prototype = Object.create(Object.prototype) <<< do
# if from-input = true: repos is triggered from user input of input box,
# so we have to debounce if v is modified.
if @input => @update-input {now: !from-input}

if module? => module.exports = ldslider
else if window? => window.ldSlider = window.ldslider = ldslider
Loading

0 comments on commit 85a4860

Please sign in to comment.