@quenty/basicpane 3.2.2 → 3.3.0-canary.241.a4e8214.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/package.json +6 -5
- package/src/Client/BasicPane.lua +17 -0
- package/src/Client/BasicPaneUtils.lua +75 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.3.0-canary.241.a4e8214.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/basicpane@3.2.2...@quenty/basicpane@3.3.0-canary.241.a4e8214.0) (2022-01-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add BasicPaneUtils and BasicPane.isBasicPane(value) ([0acc78d](https://github.com/Quenty/NevermoreEngine/commit/0acc78d3d28606e036549ffae31fe75902fc45bc))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [3.2.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/basicpane@3.2.1...@quenty/basicpane@3.2.2) (2021-12-30)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/basicpane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/basicpane",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0-canary.241.a4e8214.0",
|
|
4
4
|
"description": "Base UI object with visibility and a maid",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/loader": "
|
|
29
|
-
"@quenty/maid": "
|
|
30
|
-
"@quenty/
|
|
28
|
+
"@quenty/loader": "3.2.0-canary.241.a4e8214.0",
|
|
29
|
+
"@quenty/maid": "2.0.2",
|
|
30
|
+
"@quenty/rx": "3.6.0-canary.241.a4e8214.0",
|
|
31
|
+
"@quenty/signal": "2.1.0-canary.241.a4e8214.0"
|
|
31
32
|
},
|
|
32
33
|
"publishConfig": {
|
|
33
34
|
"access": "public"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "a4e821471f35998d63f38a4f4a578e07b4e79035"
|
|
36
37
|
}
|
package/src/Client/BasicPane.lua
CHANGED
|
@@ -12,6 +12,23 @@ local BasicPane = {}
|
|
|
12
12
|
BasicPane.__index = BasicPane
|
|
13
13
|
BasicPane.ClassName = "BasicPane"
|
|
14
14
|
|
|
15
|
+
--[=[
|
|
16
|
+
Returns whether the value is a basic pane
|
|
17
|
+
@param value any
|
|
18
|
+
@return boolean
|
|
19
|
+
]=]
|
|
20
|
+
function BasicPane.isBasicPane(value)
|
|
21
|
+
return type(value) == "table"
|
|
22
|
+
and Maid.isMaid(value._maid)
|
|
23
|
+
and Signal.isSignal(value.VisibleChanged)
|
|
24
|
+
and type(value.SetVisible) == "function"
|
|
25
|
+
and type(value.IsVisible) == "function"
|
|
26
|
+
and type(value.Show) == "function"
|
|
27
|
+
and type(value.Hide) == "function"
|
|
28
|
+
and type(value.Toggle) == "function"
|
|
29
|
+
and type(value.Destroy) == "function"
|
|
30
|
+
end
|
|
31
|
+
|
|
15
32
|
--[=[
|
|
16
33
|
Gui object which can be reparented or whatever
|
|
17
34
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class BasicPaneUtils
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local Observable = require("Observable")
|
|
8
|
+
local Maid = require("Maid")
|
|
9
|
+
local Rx = require("Rx")
|
|
10
|
+
local BasicPane = require("BasicPane")
|
|
11
|
+
|
|
12
|
+
local BasicPaneUtils = {}
|
|
13
|
+
|
|
14
|
+
--[=[
|
|
15
|
+
Observes visibility
|
|
16
|
+
@param basicPane BasicPane
|
|
17
|
+
@return Observable<boolean>
|
|
18
|
+
]=]
|
|
19
|
+
function BasicPaneUtils.observeVisible(basicPane)
|
|
20
|
+
assert(BasicPane.isBasicPane(basicPane), "Bad BasicPane")
|
|
21
|
+
|
|
22
|
+
return Observable.new(function(sub)
|
|
23
|
+
local maid = Maid.new()
|
|
24
|
+
|
|
25
|
+
maid:GiveTask(basicPane.VisibleChanged:Connect(function(isVisible)
|
|
26
|
+
sub:Fire(isVisible)
|
|
27
|
+
end))
|
|
28
|
+
sub:Fire(basicPane:IsVisible())
|
|
29
|
+
|
|
30
|
+
return maid
|
|
31
|
+
end)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
--[=[
|
|
35
|
+
Observes percent visibility
|
|
36
|
+
@param basicPane BasicPane
|
|
37
|
+
@return Observable<number>
|
|
38
|
+
]=]
|
|
39
|
+
function BasicPaneUtils.observePercentVisible(basicPane)
|
|
40
|
+
assert(BasicPane.isBasicPane(basicPane), "Bad BasicPane")
|
|
41
|
+
|
|
42
|
+
return BasicPaneUtils.observeVisible(basicPane):Pipe({
|
|
43
|
+
Rx.map(function(visible)
|
|
44
|
+
return visible and 1 or 0
|
|
45
|
+
end);
|
|
46
|
+
Rx.startWith({0}); -- Ensure fade in every time.
|
|
47
|
+
})
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
--[=[
|
|
51
|
+
Convert percentVisible observable to transparency
|
|
52
|
+
|
|
53
|
+
@function toTransparency
|
|
54
|
+
@param source Observable<number>
|
|
55
|
+
@return Observable<number>
|
|
56
|
+
@within BasicPaneUtils
|
|
57
|
+
]=]
|
|
58
|
+
BasicPaneUtils.toTransparency = Rx.map(function(value)
|
|
59
|
+
return 1 - value
|
|
60
|
+
end)
|
|
61
|
+
|
|
62
|
+
--[=[
|
|
63
|
+
Observes showing a basic pane
|
|
64
|
+
@param basicPane BasicPane
|
|
65
|
+
@return Observable<boolean>
|
|
66
|
+
]=]
|
|
67
|
+
function BasicPaneUtils.observeShow(basicPane)
|
|
68
|
+
return BasicPaneUtils.observeVisible(basicPane):Pipe({
|
|
69
|
+
Rx.where(function(isVisible)
|
|
70
|
+
return isVisible
|
|
71
|
+
end)
|
|
72
|
+
})
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
return BasicPaneUtils
|