@quenty/scrollingframe 12.18.1 → 12.20.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 +14 -0
- package/package.json +3 -3
- package/src/Client/ScrollModel.lua +42 -11
- package/src/Client/Scrollbar.lua +37 -11
- package/src/Client/ScrollingFrame.lua +67 -39
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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
|
+
# [12.20.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scrollingframe@12.19.0...@quenty/scrollingframe@12.20.0) (2026-07-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/scrollingframe
|
|
9
|
+
|
|
10
|
+
# [12.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scrollingframe@12.18.1...@quenty/scrollingframe@12.19.0) (2026-07-14)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **lint:** resolve selene and moonwave issues from strict conversions ([d427005](https://github.com/Quenty/NevermoreEngine/commit/d42700569ecb085fee4166c5bfdad382dd8442c2))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- **scrollingframe:** convert package to --!strict ([bd5908a](https://github.com/Quenty/NevermoreEngine/commit/bd5908afefafaaa181cb1d72a85176d1838adcfa))
|
|
19
|
+
|
|
6
20
|
## [12.18.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scrollingframe@12.18.0...@quenty/scrollingframe@12.18.1) (2026-05-30)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @quenty/scrollingframe
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/scrollingframe",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.20.0",
|
|
4
4
|
"description": "Creates an inertia based scrolling frame that is animated and has inertia frames Alternative to a Roblox ScrollingFrame with inertia scrolling and complete control over behavior and style",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@quenty/loader": "10.11.0",
|
|
32
|
-
"@quenty/maid": "3.
|
|
32
|
+
"@quenty/maid": "3.10.0",
|
|
33
33
|
"@quenty/signal": "7.13.1",
|
|
34
34
|
"@quenty/spring": "10.12.0",
|
|
35
35
|
"@quenty/table": "3.9.2"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "647acfad93dca41c38f59cda247d2bfc0fff36d4"
|
|
41
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Scrolling model for scrolling frame
|
|
4
4
|
@class ScrollModel
|
|
@@ -15,8 +15,37 @@ ScrollModel._min = 0
|
|
|
15
15
|
ScrollModel._max = 100
|
|
16
16
|
ScrollModel._viewSize = 50
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
export type ScrollModel = typeof(setmetatable(
|
|
19
|
+
{} :: {
|
|
20
|
+
_min: number,
|
|
21
|
+
_max: number,
|
|
22
|
+
_viewSize: number,
|
|
23
|
+
_spring: Spring.Spring<number>,
|
|
24
|
+
|
|
25
|
+
TotalContentLength: number,
|
|
26
|
+
ViewSize: number,
|
|
27
|
+
Max: number,
|
|
28
|
+
ContentMax: number,
|
|
29
|
+
Min: number,
|
|
30
|
+
ContentMin: number,
|
|
31
|
+
Position: number,
|
|
32
|
+
BackBounceInputRange: number,
|
|
33
|
+
BackBounceRenderRange: number,
|
|
34
|
+
ContentScrollPercentSize: number,
|
|
35
|
+
RenderedContentScrollPercentSize: number,
|
|
36
|
+
ContentScrollPercent: number,
|
|
37
|
+
RenderedContentScrollPercent: number,
|
|
38
|
+
BoundedRenderPosition: number,
|
|
39
|
+
Velocity: number,
|
|
40
|
+
Target: number,
|
|
41
|
+
TargetContentScrollPercent: number,
|
|
42
|
+
AtRest: boolean,
|
|
43
|
+
},
|
|
44
|
+
{} :: typeof({ __index = ScrollModel })
|
|
45
|
+
))
|
|
46
|
+
|
|
47
|
+
function ScrollModel.new(): ScrollModel
|
|
48
|
+
local self: ScrollModel = setmetatable({} :: any, ScrollModel)
|
|
20
49
|
|
|
21
50
|
self._spring = Spring.new(0)
|
|
22
51
|
self._spring.Speed = 20
|
|
@@ -24,11 +53,11 @@ function ScrollModel.new()
|
|
|
24
53
|
return self
|
|
25
54
|
end
|
|
26
55
|
|
|
27
|
-
function ScrollModel
|
|
56
|
+
function ScrollModel._getTimesOverBounds(self: ScrollModel, position: number): number
|
|
28
57
|
return self:GetDisplacementPastBounds(position) / self.BackBounceInputRange
|
|
29
58
|
end
|
|
30
59
|
|
|
31
|
-
function ScrollModel
|
|
60
|
+
function ScrollModel.GetDisplacementPastBounds(self: ScrollModel, position: number): number
|
|
32
61
|
if position > self.ContentMax then
|
|
33
62
|
return position - self.ContentMax
|
|
34
63
|
elseif position < self.ContentMin then
|
|
@@ -38,11 +67,13 @@ function ScrollModel:GetDisplacementPastBounds(position)
|
|
|
38
67
|
end
|
|
39
68
|
end
|
|
40
69
|
|
|
41
|
-
function ScrollModel
|
|
70
|
+
function ScrollModel.GetScale(_self: ScrollModel, timesOverBounds: number): number
|
|
42
71
|
return 1 - 0.5 ^ math.abs(timesOverBounds)
|
|
43
72
|
end
|
|
44
73
|
|
|
45
|
-
|
|
74
|
+
local rawScrollModel = ScrollModel :: any
|
|
75
|
+
|
|
76
|
+
rawScrollModel.__index = function(self: any, index: string): any
|
|
46
77
|
if index == "TotalContentLength" then
|
|
47
78
|
return self._max - self._min
|
|
48
79
|
elseif index == "ViewSize" then
|
|
@@ -100,15 +131,15 @@ function ScrollModel:__index(index)
|
|
|
100
131
|
return self._spring.Target
|
|
101
132
|
elseif index == "AtRest" then
|
|
102
133
|
return math.abs(self._spring.Target - self._spring.Position) < 1e-5 and math.abs(self._spring.Velocity) < 1e-5
|
|
103
|
-
elseif
|
|
104
|
-
return
|
|
134
|
+
elseif rawScrollModel[index] then
|
|
135
|
+
return rawScrollModel[index]
|
|
105
136
|
else
|
|
106
137
|
error(string.format("[ScrollModel] - '%s' is not a valid member", tostring(index)))
|
|
107
138
|
end
|
|
108
139
|
end
|
|
109
140
|
|
|
110
|
-
function
|
|
111
|
-
if
|
|
141
|
+
rawScrollModel.__newindex = function(self: any, index: string, value: any): ()
|
|
142
|
+
if rawScrollModel[index] or index == "_spring" then
|
|
112
143
|
rawset(self, index, value)
|
|
113
144
|
elseif index == "Min" or index == "ContentMin" then
|
|
114
145
|
self._min = value
|
package/src/Client/Scrollbar.lua
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
@class Scrollbar
|
|
4
4
|
]=]
|
|
@@ -7,15 +7,41 @@ local require = require(script.Parent.loader).load(script)
|
|
|
7
7
|
|
|
8
8
|
local Maid = require("Maid")
|
|
9
9
|
local SCROLL_TYPE = require("SCROLL_TYPE")
|
|
10
|
+
local ScrollModel = require("ScrollModel")
|
|
10
11
|
local Signal = require("Signal")
|
|
11
12
|
local Table = require("Table")
|
|
12
13
|
|
|
14
|
+
type ScrollType = typeof(SCROLL_TYPE.Vertical)
|
|
15
|
+
|
|
16
|
+
-- ScrollingFrame is still nonstrict and exports no type; type the surface we use.
|
|
17
|
+
type ScrollingFrameLike = {
|
|
18
|
+
GetModel: (self: ScrollingFrameLike) -> ScrollModel.ScrollModel,
|
|
19
|
+
StartScrollbarScrolling: (
|
|
20
|
+
self: ScrollingFrameLike,
|
|
21
|
+
scrollbarContainer: Instance,
|
|
22
|
+
inputBeganObject: InputObject
|
|
23
|
+
) -> Maid.Maid,
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
local Scrollbar = {}
|
|
14
27
|
Scrollbar.ClassName = "Scrollbar"
|
|
15
28
|
Scrollbar.__index = Scrollbar
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
export type Scrollbar = typeof(setmetatable(
|
|
31
|
+
{} :: {
|
|
32
|
+
Gui: GuiObject,
|
|
33
|
+
DraggingBegan: Signal.Signal<()>,
|
|
34
|
+
_maid: Maid.Maid,
|
|
35
|
+
_container: Instance,
|
|
36
|
+
_scrollType: ScrollType,
|
|
37
|
+
_scrollingFrame: ScrollingFrameLike,
|
|
38
|
+
_model: ScrollModel.ScrollModel,
|
|
39
|
+
},
|
|
40
|
+
{} :: typeof({ __index = Scrollbar })
|
|
41
|
+
))
|
|
42
|
+
|
|
43
|
+
function Scrollbar.new(gui: GuiObject, scrollType: ScrollType?): Scrollbar
|
|
44
|
+
local self: Scrollbar = setmetatable({} :: any, Scrollbar)
|
|
19
45
|
|
|
20
46
|
self.Gui = gui or error("No gui")
|
|
21
47
|
self.DraggingBegan = Signal.new()
|
|
@@ -27,7 +53,7 @@ function Scrollbar.new(gui, scrollType)
|
|
|
27
53
|
return self
|
|
28
54
|
end
|
|
29
55
|
|
|
30
|
-
function Scrollbar.fromContainer(container, scrollType)
|
|
56
|
+
function Scrollbar.fromContainer(container: GuiObject, scrollType: ScrollType?): Scrollbar
|
|
31
57
|
local gui = Instance.new("ImageButton")
|
|
32
58
|
gui.Size = UDim2.fromScale(1, 1)
|
|
33
59
|
gui.Name = "ScrollBar"
|
|
@@ -42,12 +68,12 @@ function Scrollbar.fromContainer(container, scrollType)
|
|
|
42
68
|
return Scrollbar.new(gui, scrollType)
|
|
43
69
|
end
|
|
44
70
|
|
|
45
|
-
function Scrollbar
|
|
71
|
+
function Scrollbar.SetScrollType(self: Scrollbar, scrollType: ScrollType): ()
|
|
46
72
|
assert(Table.contains(SCROLL_TYPE, scrollType))
|
|
47
73
|
self._scrollType = scrollType
|
|
48
74
|
end
|
|
49
75
|
|
|
50
|
-
function Scrollbar
|
|
76
|
+
function Scrollbar.SetScrollingFrame(self: Scrollbar, scrollingFrame: ScrollingFrameLike): ()
|
|
51
77
|
self._scrollingFrame = scrollingFrame or error("No scrollingFrame")
|
|
52
78
|
self._model = self._scrollingFrame:GetModel()
|
|
53
79
|
|
|
@@ -60,7 +86,7 @@ function Scrollbar:SetScrollingFrame(scrollingFrame)
|
|
|
60
86
|
self:UpdateRender()
|
|
61
87
|
end
|
|
62
88
|
|
|
63
|
-
function Scrollbar
|
|
89
|
+
function Scrollbar.UpdateRender(self: Scrollbar): ()
|
|
64
90
|
if self._model.TotalContentLength > self._model.ViewSize then
|
|
65
91
|
local percentSize = self._model.RenderedContentScrollPercentSize
|
|
66
92
|
local pos = (1 - percentSize) * self._model.RenderedContentScrollPercent
|
|
@@ -81,10 +107,10 @@ function Scrollbar:UpdateRender()
|
|
|
81
107
|
end
|
|
82
108
|
end
|
|
83
109
|
|
|
84
|
-
function Scrollbar
|
|
85
|
-
self._maid:DoCleaning()
|
|
86
|
-
self._maid = nil
|
|
87
|
-
setmetatable(self, nil)
|
|
110
|
+
function Scrollbar.Destroy(self: Scrollbar): ()
|
|
111
|
+
self._maid:DoCleaning();
|
|
112
|
+
(self :: any)._maid = nil
|
|
113
|
+
setmetatable(self :: any, nil)
|
|
88
114
|
end
|
|
89
115
|
|
|
90
116
|
return Scrollbar
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Creates an inertia based scrolling frame that is animated and has inertia frames
|
|
4
4
|
Alternative to a Roblox ScrollingFrame with inertia scrolling and complete control over behavior and style.
|
|
@@ -21,6 +21,26 @@ local ScrollingFrame = {}
|
|
|
21
21
|
ScrollingFrame.ClassName = "ScrollingFrame"
|
|
22
22
|
ScrollingFrame.__index = ScrollingFrame
|
|
23
23
|
|
|
24
|
+
export type ScrollType = {
|
|
25
|
+
Direction: string,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ScrollingFrameOptions = {
|
|
29
|
+
OnClick: ((inputObject: InputObject) -> ())?,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type ScrollingFrame = typeof(setmetatable(
|
|
33
|
+
{} :: {
|
|
34
|
+
_maid: Maid.Maid,
|
|
35
|
+
Gui: GuiObject,
|
|
36
|
+
_container: GuiObject,
|
|
37
|
+
_scrollType: ScrollType,
|
|
38
|
+
_scrollbars: { any },
|
|
39
|
+
_model: ScrollModel.ScrollModel,
|
|
40
|
+
},
|
|
41
|
+
{} :: typeof({ __index = ScrollingFrame })
|
|
42
|
+
))
|
|
43
|
+
|
|
24
44
|
--[=[
|
|
25
45
|
Creates a new ScrollingFrame which can be used. Prefer Container.Active = true so scroll wheel works.
|
|
26
46
|
Container should be in a Frame with ClipsDescendants = true
|
|
@@ -28,12 +48,12 @@ ScrollingFrame.__index = ScrollingFrame
|
|
|
28
48
|
@param gui BaseGui -- Gui to use
|
|
29
49
|
@return ScrollingFrame
|
|
30
50
|
]=]
|
|
31
|
-
function ScrollingFrame.new(gui)
|
|
32
|
-
local self = setmetatable({}, ScrollingFrame)
|
|
51
|
+
function ScrollingFrame.new(gui: GuiObject): ScrollingFrame
|
|
52
|
+
local self: ScrollingFrame = setmetatable({} :: any, ScrollingFrame)
|
|
33
53
|
|
|
34
54
|
self._maid = Maid.new()
|
|
35
55
|
self.Gui = gui or error("No Gui")
|
|
36
|
-
self._container = self.Gui.Parent or error("No container")
|
|
56
|
+
self._container = (self.Gui.Parent or error("No container")) :: GuiObject
|
|
37
57
|
self._scrollType = SCROLL_TYPE.Vertical
|
|
38
58
|
|
|
39
59
|
self._scrollbars = {}
|
|
@@ -59,12 +79,12 @@ function ScrollingFrame.new(gui)
|
|
|
59
79
|
end
|
|
60
80
|
|
|
61
81
|
-- Sets the scroll type for the frame
|
|
62
|
-
function ScrollingFrame
|
|
63
|
-
assert(Table.contains(SCROLL_TYPE, scrollType))
|
|
82
|
+
function ScrollingFrame.SetScrollType(self: ScrollingFrame, scrollType: ScrollType): ()
|
|
83
|
+
assert(Table.contains(SCROLL_TYPE :: any, scrollType))
|
|
64
84
|
self._scrollType = scrollType
|
|
65
85
|
end
|
|
66
86
|
|
|
67
|
-
function ScrollingFrame
|
|
87
|
+
function ScrollingFrame.AddScrollbar(self: ScrollingFrame, scrollbar: any): ()
|
|
68
88
|
assert(scrollbar, "Bad scrollbar")
|
|
69
89
|
scrollbar:SetScrollingFrame(self)
|
|
70
90
|
|
|
@@ -72,7 +92,7 @@ function ScrollingFrame:AddScrollbar(scrollbar)
|
|
|
72
92
|
self._maid[scrollbar] = scrollbar
|
|
73
93
|
end
|
|
74
94
|
|
|
75
|
-
function ScrollingFrame
|
|
95
|
+
function ScrollingFrame.RemoveScrollbar(self: ScrollingFrame, scrollbar: any): ()
|
|
76
96
|
local index = Table.getIndex(self._scrollbars, scrollbar)
|
|
77
97
|
if index then
|
|
78
98
|
table.remove(self._scrollbars, index)
|
|
@@ -81,34 +101,34 @@ function ScrollingFrame:RemoveScrollbar(scrollbar)
|
|
|
81
101
|
end
|
|
82
102
|
|
|
83
103
|
-- Scrolls to the position in pixels offset
|
|
84
|
-
function ScrollingFrame
|
|
104
|
+
function ScrollingFrame.ScrollTo(self: ScrollingFrame, position: number, doNotAnimate: boolean?): ()
|
|
85
105
|
self._model.Target = position
|
|
86
106
|
if doNotAnimate then
|
|
87
|
-
self._model.position = self._model.Target
|
|
107
|
+
(self._model :: any).position = self._model.Target
|
|
88
108
|
self._model.Velocity = 0
|
|
89
109
|
end
|
|
90
110
|
end
|
|
91
111
|
|
|
92
112
|
-- Scrolls to the top
|
|
93
|
-
function ScrollingFrame
|
|
113
|
+
function ScrollingFrame.ScrollToTop(self: ScrollingFrame, doNotAnimate: boolean?): ()
|
|
94
114
|
self:ScrollTo(self._model.Min, doNotAnimate)
|
|
95
115
|
end
|
|
96
116
|
|
|
97
117
|
-- Scrolls to the bottom
|
|
98
|
-
function ScrollingFrame
|
|
118
|
+
function ScrollingFrame.ScrollToBottom(self: ScrollingFrame, doNotAnimate: boolean?): ()
|
|
99
119
|
self:ScrollTo(self._model.Max, doNotAnimate)
|
|
100
120
|
end
|
|
101
121
|
|
|
102
|
-
function ScrollingFrame
|
|
122
|
+
function ScrollingFrame.GetModel(self: ScrollingFrame): ScrollModel.ScrollModel
|
|
103
123
|
return self._model
|
|
104
124
|
end
|
|
105
125
|
|
|
106
|
-
function ScrollingFrame
|
|
107
|
-
self._model.TotalContentLength = self.Gui.AbsoluteSize[self._scrollType.Direction]
|
|
108
|
-
self._model.ViewSize = self._container.AbsoluteSize[self._scrollType.Direction]
|
|
126
|
+
function ScrollingFrame._updateScrollerSize(self: ScrollingFrame): ()
|
|
127
|
+
self._model.TotalContentLength = (self.Gui.AbsoluteSize :: any)[self._scrollType.Direction]
|
|
128
|
+
self._model.ViewSize = (self._container.AbsoluteSize :: any)[self._scrollType.Direction]
|
|
109
129
|
end
|
|
110
130
|
|
|
111
|
-
function ScrollingFrame
|
|
131
|
+
function ScrollingFrame._updateRender(self: ScrollingFrame): ()
|
|
112
132
|
if self._scrollType == SCROLL_TYPE.Vertical then
|
|
113
133
|
self.Gui.Position = UDim2.new(self.Gui.Position.X, UDim.new(0, self._model.BoundedRenderPosition))
|
|
114
134
|
elseif self._scrollType == SCROLL_TYPE.Horizontal then
|
|
@@ -126,7 +146,7 @@ function ScrollingFrame:_updateRender()
|
|
|
126
146
|
end
|
|
127
147
|
end
|
|
128
148
|
|
|
129
|
-
function ScrollingFrame
|
|
149
|
+
function ScrollingFrame.StopDrag(self: ScrollingFrame): ()
|
|
130
150
|
local position = self._model.Position
|
|
131
151
|
|
|
132
152
|
if self._model:GetDisplacementPastBounds(position) == 0 then
|
|
@@ -141,7 +161,7 @@ function ScrollingFrame:StopDrag()
|
|
|
141
161
|
end
|
|
142
162
|
|
|
143
163
|
-- Scrolls until model is at rest
|
|
144
|
-
function ScrollingFrame
|
|
164
|
+
function ScrollingFrame._freeScroll(self: ScrollingFrame, lowPriority: boolean?): ()
|
|
145
165
|
if lowPriority and self._maid._updateMaid then
|
|
146
166
|
return
|
|
147
167
|
end
|
|
@@ -161,14 +181,14 @@ end
|
|
|
161
181
|
|
|
162
182
|
--
|
|
163
183
|
-- @param[opt=1] strength
|
|
164
|
-
function ScrollingFrame
|
|
165
|
-
|
|
184
|
+
function ScrollingFrame._getVelocityTracker(self: ScrollingFrame, strength: number?): () -> ()
|
|
185
|
+
local actualStrength = strength or 1
|
|
166
186
|
self._model.Velocity = 0
|
|
167
187
|
|
|
168
188
|
local lastUpdate = tick()
|
|
169
189
|
local lastPos = self._model.Position
|
|
170
190
|
|
|
171
|
-
return function()
|
|
191
|
+
return function(): ()
|
|
172
192
|
local pos = self._model.Position
|
|
173
193
|
local elapsed = tick() - lastUpdate
|
|
174
194
|
local delta = lastPos - pos
|
|
@@ -177,19 +197,19 @@ function ScrollingFrame:_getVelocityTracker(strength)
|
|
|
177
197
|
elapsed = 0.03
|
|
178
198
|
end
|
|
179
199
|
|
|
180
|
-
self._model.Velocity = self._model.Velocity - (delta / elapsed) *
|
|
200
|
+
self._model.Velocity = self._model.Velocity - (delta / elapsed) * actualStrength
|
|
181
201
|
lastPos = pos
|
|
182
202
|
lastUpdate = tick()
|
|
183
203
|
end
|
|
184
204
|
end
|
|
185
205
|
|
|
186
|
-
function ScrollingFrame
|
|
206
|
+
function ScrollingFrame._getInputProcessor(self: ScrollingFrame, inputBeganObject: InputObject): (InputObject) -> number
|
|
187
207
|
local startPos = self._model.Position
|
|
188
208
|
local updateVelocity = self:_getVelocityTracker()
|
|
189
209
|
local originalPos = inputBeganObject.Position
|
|
190
210
|
|
|
191
|
-
return function(inputObject: InputObject)
|
|
192
|
-
local distance = (inputObject.Position - originalPos)[self._scrollType.Direction]
|
|
211
|
+
return function(inputObject: InputObject): number
|
|
212
|
+
local distance = ((inputObject.Position - originalPos) :: any)[self._scrollType.Direction]
|
|
193
213
|
local pos = startPos - distance
|
|
194
214
|
self._model.Position = pos
|
|
195
215
|
self._model.Target = pos
|
|
@@ -203,7 +223,7 @@ end
|
|
|
203
223
|
|
|
204
224
|
-- Binds input to a specific GUI
|
|
205
225
|
-- @return maid Maid -- To cleanup inputs
|
|
206
|
-
function ScrollingFrame
|
|
226
|
+
function ScrollingFrame.BindInput(self: ScrollingFrame, gui: GuiObject, options: ScrollingFrameOptions?): Maid.Maid
|
|
207
227
|
local maid = Maid.new()
|
|
208
228
|
|
|
209
229
|
maid:GiveTask(gui.InputBegan:Connect(function(inputObject)
|
|
@@ -212,7 +232,7 @@ function ScrollingFrame:BindInput(gui, options)
|
|
|
212
232
|
|
|
213
233
|
maid:GiveTask(gui.InputChanged:Connect(function(inputObject)
|
|
214
234
|
if gui.Active and inputObject.UserInputType == Enum.UserInputType.MouseWheel then
|
|
215
|
-
self._model.Target = self._model.Target - inputObject.Position.z * 80
|
|
235
|
+
self._model.Target = self._model.Target - (inputObject.Position :: any).z * 80
|
|
216
236
|
self:_freeScroll()
|
|
217
237
|
end
|
|
218
238
|
end))
|
|
@@ -221,7 +241,11 @@ function ScrollingFrame:BindInput(gui, options)
|
|
|
221
241
|
return maid
|
|
222
242
|
end
|
|
223
243
|
|
|
224
|
-
function ScrollingFrame
|
|
244
|
+
function ScrollingFrame.StartScrolling(
|
|
245
|
+
self: ScrollingFrame,
|
|
246
|
+
inputBeganObject: InputObject,
|
|
247
|
+
options: ScrollingFrameOptions?
|
|
248
|
+
): ()
|
|
225
249
|
if inputBeganObject.UserInputState ~= Enum.UserInputState.Begin then
|
|
226
250
|
-- Touch events moving into GUIs occur sometimes
|
|
227
251
|
return
|
|
@@ -262,7 +286,7 @@ function ScrollingFrame:StartScrolling(inputBeganObject, options)
|
|
|
262
286
|
end
|
|
263
287
|
end)
|
|
264
288
|
|
|
265
|
-
maid:GiveTask(UserInputService.InputEnded:Connect(function(inputObject, _)
|
|
289
|
+
maid:GiveTask(UserInputService.InputEnded:Connect(function(inputObject: InputObject, _)
|
|
266
290
|
if inputObject == inputBeganObject then
|
|
267
291
|
self:StopDrag()
|
|
268
292
|
end
|
|
@@ -276,7 +300,11 @@ function ScrollingFrame:StartScrolling(inputBeganObject, options)
|
|
|
276
300
|
end
|
|
277
301
|
end
|
|
278
302
|
|
|
279
|
-
function ScrollingFrame
|
|
303
|
+
function ScrollingFrame.StartScrollbarScrolling(
|
|
304
|
+
self: ScrollingFrame,
|
|
305
|
+
scrollbarContainer: GuiObject,
|
|
306
|
+
inputBeganObject: InputObject
|
|
307
|
+
): Maid.Maid
|
|
280
308
|
assert(scrollbarContainer, "Bad scrollbarContainer")
|
|
281
309
|
assert(inputBeganObject, "Bad inputBeganObject")
|
|
282
310
|
|
|
@@ -286,12 +314,12 @@ function ScrollingFrame:StartScrollbarScrolling(scrollbarContainer, inputBeganOb
|
|
|
286
314
|
local startPercent = self._model.ContentScrollPercent
|
|
287
315
|
local updateVelocity = self:_getVelocityTracker(0.25)
|
|
288
316
|
|
|
289
|
-
maid:GiveTask(UserInputService.InputChanged:Connect(function(inputObject)
|
|
317
|
+
maid:GiveTask(UserInputService.InputChanged:Connect(function(inputObject: InputObject)
|
|
290
318
|
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
|
|
291
319
|
local direction = self._scrollType.Direction
|
|
292
|
-
local offset = (inputObject.Position - startPosition)[direction]
|
|
320
|
+
local offset = ((inputObject.Position - startPosition) :: any)[direction]
|
|
293
321
|
local percent = offset
|
|
294
|
-
/ (scrollbarContainer.AbsoluteSize[direction] * (1 - self._model.ContentScrollPercentSize))
|
|
322
|
+
/ ((scrollbarContainer.AbsoluteSize :: any)[direction] * (1 - self._model.ContentScrollPercentSize))
|
|
295
323
|
self._model.ContentScrollPercent = startPercent + percent
|
|
296
324
|
self._model.TargetContentScrollPercent = self._model.ContentScrollPercent
|
|
297
325
|
|
|
@@ -300,7 +328,7 @@ function ScrollingFrame:StartScrollbarScrolling(scrollbarContainer, inputBeganOb
|
|
|
300
328
|
end
|
|
301
329
|
end))
|
|
302
330
|
|
|
303
|
-
maid:GiveTask(UserInputService.InputEnded:Connect(function(inputObject)
|
|
331
|
+
maid:GiveTask(UserInputService.InputEnded:Connect(function(inputObject: InputObject)
|
|
304
332
|
if inputObject == inputBeganObject then
|
|
305
333
|
self:StopDrag()
|
|
306
334
|
end
|
|
@@ -311,10 +339,10 @@ function ScrollingFrame:StartScrollbarScrolling(scrollbarContainer, inputBeganOb
|
|
|
311
339
|
return maid
|
|
312
340
|
end
|
|
313
341
|
|
|
314
|
-
function ScrollingFrame
|
|
315
|
-
self._maid:DoCleaning()
|
|
316
|
-
self._maid = nil
|
|
317
|
-
setmetatable(self, nil)
|
|
342
|
+
function ScrollingFrame.Destroy(self: ScrollingFrame): ()
|
|
343
|
+
self._maid:DoCleaning();
|
|
344
|
+
(self :: any)._maid = nil
|
|
345
|
+
setmetatable(self :: any, nil)
|
|
318
346
|
end
|
|
319
347
|
|
|
320
348
|
return ScrollingFrame
|