Skip to content

Commit

Permalink
- add setZmgr for managing z-index globally.
Browse files Browse the repository at this point in the history
 - fix bug: when `auto-z` is set to true, z value isn't calculated
   correctly.
  • Loading branch information
zbryikt committed Dec 22, 2020
1 parent e0790fa commit 9953b45
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.2.0

- add `setZmgr` for managing z-index globally.
- fix bug: when `auto-z` is set to true, z value isn't calculated correctly.


# 1.1.1

- only release `dist` files
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ Methods:
- toggle.on
- toggle.off


## Class Method

* setZmgr(zmgr): set a shared z-index manager. useful to manager widget z-index globally.
this manager should provide following methods:
- add(baseVal, size): return actual added value.
- baseVal: hint value for the z-index we'd like to use
- size: hint size about how large the object we added is
- remove(val): remove val ( returned by add ) from this manager.


## Styling and Structure

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.
Expand Down
27 changes: 19 additions & 8 deletions dist/ldld.js

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

2 changes: 1 addition & 1 deletion dist/ldld.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 @@ -6,7 +6,7 @@
"dist/**/*"
],
"description": "loader manipulation library",
"version": "1.1.1",
"version": "1.2.0",
"homepage": "https://loading.io/lib/loader/",
"repository": {
"type": "git",
Expand Down
15 changes: 10 additions & 5 deletions src/ldld.ls
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,22 @@
if @opt.ctrl => @render!
if !@opt.auto-z => return res!
if running =>
@z = z = (ldLoader.zstack[* - 1] or 0) + @opt.base-z
@root.map ~> it.style.zIndex = z
ldLoader.zstack.push z
if ldLoader.zmgr => @z = ldLoader.zmgr.add @opt.base-z
else
@z = (ldLoader.zstack[* - 1] or @opt.base-z) + 1
ldLoader.zstack.push z
@root.map ~> it.style.zIndex = @z
else
if (idx = ldLoader.zstack.indexOf(@z)) < 0 => return res!
if ldLoader.zmgr => ldLoader.zmgr.remove @z
else
if (idx = ldLoader.zstack.indexOf(@z)) < 0 => return res!
ldLoader.zstack.splice(idx, 1)
@root.map ~> it.style.zIndex = ""
ldLoader.zstack.splice(idx, 1)
res!

ldLoader <<< do
zstack: []
set-zmgr: -> @zmgr = it

window.ldLoader = ldLoader
)!

0 comments on commit 9953b45

Please sign in to comment.