Skip to content

Commit 9953b45

Browse files
committed
- add setZmgr for managing z-index globally.
- fix bug: when `auto-z` is set to true, z value isn't calculated correctly.
1 parent e0790fa commit 9953b45

File tree

7 files changed

+49
-16
lines changed

7 files changed

+49
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.2.0
2+
3+
- add `setZmgr` for managing z-index globally.
4+
- fix bug: when `auto-z` is set to true, z value isn't calculated correctly.
5+
6+
17
# 1.1.1
28

39
- only release `dist` files

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ Methods:
4343
- toggle.on
4444
- toggle.off
4545

46+
47+
## Class Method
48+
49+
* setZmgr(zmgr): set a shared z-index manager. useful to manager widget z-index globally.
50+
this manager should provide following methods:
51+
- add(baseVal, size): return actual added value.
52+
- baseVal: hint value for the z-index we'd like to use
53+
- size: hint size about how large the object we added is
54+
- remove(val): remove val ( returned by add ) from this manager.
55+
56+
4657
## Styling and Structure
4758

4859
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.

dist/ldld.js

Lines changed: 19 additions & 8 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.

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dist/**/*"
77
],
88
"description": "loader manipulation library",
9-
"version": "1.1.1",
9+
"version": "1.2.0",
1010
"homepage": "https://loading.io/lib/loader/",
1111
"repository": {
1212
"type": "git",

src/ldld.ls

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,22 @@
5757
if @opt.ctrl => @render!
5858
if !@opt.auto-z => return res!
5959
if running =>
60-
@z = z = (ldLoader.zstack[* - 1] or 0) + @opt.base-z
61-
@root.map ~> it.style.zIndex = z
62-
ldLoader.zstack.push z
60+
if ldLoader.zmgr => @z = ldLoader.zmgr.add @opt.base-z
61+
else
62+
@z = (ldLoader.zstack[* - 1] or @opt.base-z) + 1
63+
ldLoader.zstack.push z
64+
@root.map ~> it.style.zIndex = @z
6365
else
64-
if (idx = ldLoader.zstack.indexOf(@z)) < 0 => return res!
66+
if ldLoader.zmgr => ldLoader.zmgr.remove @z
67+
else
68+
if (idx = ldLoader.zstack.indexOf(@z)) < 0 => return res!
69+
ldLoader.zstack.splice(idx, 1)
6570
@root.map ~> it.style.zIndex = ""
66-
ldLoader.zstack.splice(idx, 1)
6771
res!
6872

6973
ldLoader <<< do
7074
zstack: []
75+
set-zmgr: -> @zmgr = it
7176

7277
window.ldLoader = ldLoader
7378
)!

0 commit comments

Comments
 (0)