Skip to content

Commit eb9d0e6

Browse files
committed
- deprecate ldLoader. use ldloader instead.
1 parent 9953b45 commit eb9d0e6

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# ldLoader
1+
# ldloader
22

3-
handy library to manipulate loader's state. for more information, please check [ldLoader documentation](https://loading.io/lib/loader/).
3+
handy library to manipulate loader's state. for more information, please check [ldloader documentation](https://loading.io/lib/loader/).
44

55

66
## Usage
77

88
create an object for each loader you want to use:
99

1010
````
11-
var ldld = new ldLoader(config);
11+
var ldld = new ldloader(config);
1212
````
1313

1414

1515
config includes following options:
1616

1717
* root: element for your loader. default null
1818
- could be css selector, element, or array of css selectors/elements.
19-
- ldLoader will create one automatically if omitted, and append it under container.
20-
- if root is an array, ldLoader instance will work on every element in the array.
19+
- ldloader will create one automatically if omitted, and append it under container.
20+
- if root is an array, ldloader instance will work on every element in the array.
2121
* container: where root should be put in. default null.
2222
- will be root.parentNode if omitted.
2323
- will be document.body if both root and container is omitted.
@@ -28,10 +28,10 @@ config includes following options:
2828
* inactive-class: class added to root when loader is toggled off. default is null.
2929
* auto-z: update root's z-index automatically. default true.
3030
* base-z: the minimal z-index of root. default 10000.
31-
- with auto-z, ldLoader keeps track of all loaders' z-index and always use larger z-index for newly toggled loaders. base-z is then used as a base value for all auto-z loaders.
31+
- with auto-z, ldloader keeps track of all loaders' z-index and always use larger z-index for newly toggled loaders. base-z is then used as a base value for all auto-z loaders.
3232
* ctrl: custom animation control unit. should at least contains a member function "step(t)".
3333
- step(t): will be invoked repeatedly by requestAnimationFrame during loading period. context (aka this) will be root.
34-
* atomic: default true. when atomic is false, you will need N ldLoader.off() call to dismiss ldLoader if there was already N ldLoader.on() call.
34+
* atomic: default true. when atomic is false, you will need N ldloader.off() call to dismiss ldloader if there was already N ldloader.on() call.
3535

3636
Methods:
3737
* on(delay): toggle loader on. return promise. (if delay is provided, wait delay(ms) before on )
@@ -56,9 +56,9 @@ Methods:
5656

5757
## Styling and Structure
5858

59-
There is no constraint about how ldLoader's DOM structure should be. Basically it contains an element for loader, and the element's parent in which the loader is shown. You control all the animation and effects based on ```active-class``` toggled by ldLoader.
59+
There is no constraint about how ldloader's DOM structure should be. Basically it contains an element for loader, and the element's parent in which the loader is shown. You control all the animation and effects based on ```active-class``` toggled by ldloader.
6060

61-
For convenience, ldLoader is shipped with some builtin css for simple usage:
61+
For convenience, ldloader is shipped with some builtin css for simple usage:
6262

6363
* .ldld.bare - rotating double ring, placed at where it should be.
6464
* .ldld.default - rotating double ring centered in it's container. container should have style position: relatve/absolute/fixed.
@@ -72,15 +72,15 @@ For convenience, ldLoader is shipped with some builtin css for simple usage:
7272
* .ldld.light - rgba(255,255,255,.5)
7373
* .ldld.dark - rgba(0,0,0,.5)
7474

75-
You can also use ldLoader along with ```loading-btn``` and ```loading.css```:
75+
You can also use ldloader along with ```loading-btn``` and ```loading.css```:
7676

7777
```
7878
<div class="btn ld-ext-right">
7979
Load
8080
<div class="ld ld-ball ld-bounce"></div>
8181
</div>
8282
<script>
83-
var ldld = new ldLoader({root: ".ld-ext-right"});
83+
var ldld = new ldloader({root: ".ld-ext-right"});
8484
ldld.on(); ldld.off(1000);
8585
</script>
8686
```

dist/ldld.js

Lines changed: 18 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ldld.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ldld.ls

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
(->
2-
ldLoader = (opt={}) ->
2+
ldloader = (opt={}) ->
33
@opt = {active-class: \running, base-z: 4000, auto-z: false, class-name: '', atomic: true} <<< opt
44
<[root container]>.map (n) ~> if opt[n] =>
55
@[n] = (if Array.isArray(opt[n]) => opt[n] else [opt[n]]).map ->
66
ret = if typeof(it) == \string => document.querySelector(it) else it
7-
if !ret => console.warn "[ldLoader] warning: no node found for #it"
7+
if !ret => console.warn "[ldloader] warning: no node found for #it"
88
ret
99
if !@container => @container = if @root => @root.map(-> it.parentNode) else [document.body]
1010
if !@root => @root = @container.map ->
@@ -18,7 +18,7 @@
1818
@ <<< running: false, count: 0
1919
@
2020

21-
ldLoader.prototype = Object.create(Object.prototype) <<< do
21+
ldloader.prototype = Object.create(Object.prototype) <<< do
2222
is-on: -> return @running
2323
on: (delay=0) -> @toggle true, delay
2424
off: (delay=0, force = false) -> @toggle false, delay, force
@@ -57,22 +57,23 @@
5757
if @opt.ctrl => @render!
5858
if !@opt.auto-z => return res!
5959
if running =>
60-
if ldLoader.zmgr => @z = ldLoader.zmgr.add @opt.base-z
60+
if ldloader.zmgr => @z = ldloader.zmgr.add @opt.base-z
6161
else
62-
@z = (ldLoader.zstack[* - 1] or @opt.base-z) + 1
63-
ldLoader.zstack.push z
62+
@z = (ldloader.zstack[* - 1] or @opt.base-z) + 1
63+
ldloader.zstack.push z
6464
@root.map ~> it.style.zIndex = @z
6565
else
66-
if ldLoader.zmgr => ldLoader.zmgr.remove @z
66+
if ldloader.zmgr => ldloader.zmgr.remove @z
6767
else
68-
if (idx = ldLoader.zstack.indexOf(@z)) < 0 => return res!
69-
ldLoader.zstack.splice(idx, 1)
68+
if (idx = ldloader.zstack.indexOf(@z)) < 0 => return res!
69+
ldloader.zstack.splice(idx, 1)
7070
@root.map ~> it.style.zIndex = ""
7171
res!
7272

73-
ldLoader <<< do
73+
ldloader <<< do
7474
zstack: []
7575
set-zmgr: -> @zmgr = it
7676

77-
window.ldLoader = ldLoader
77+
if module? => module.exports = ldloader
78+
else window.ldloader = window.ldLoader = ldloader
7879
)!

0 commit comments

Comments
 (0)