fixed tween udim and other type issue
This commit is contained in:
parent
58821a6921
commit
341e9d5d7b
3 changed files with 28 additions and 25 deletions
|
|
@ -19,12 +19,10 @@ image.BackgroundTransparency = 1;
|
||||||
-- const
|
-- const
|
||||||
local white = Color3.fromRGB(255,255,255);
|
local white = Color3.fromRGB(255,255,255);
|
||||||
local scrollMut = 100; -- Used for multiply input when using mosue scroll
|
local scrollMut = 100; -- Used for multiply input when using mosue scroll
|
||||||
local elasticMut = 20; -- Used for multiply input when overscrolling
|
local elasticMut = 18; -- Used for multiply input when overscrolling
|
||||||
local fitTime = 0.22; -- Used for reset overscroll when mouse scroll
|
local fitTime = 0.26; -- Used for reset overscroll when mouse scroll
|
||||||
local tweenTime = 0.63; -- Used for tween time
|
local tweenTime = 0.71; -- Used for tween time
|
||||||
local mouseUpMut = 18; -- Used for multiply input when drag input ended
|
local mouseUpMut = 6; -- Used for multiply input when drag input ended
|
||||||
local dragRestMut = 5; -- Used for multiply input when reset overscroll from drag input
|
|
||||||
local dragOverMut = 0.3; -- Used for multiply input when overscrolling from drag input
|
|
||||||
local scrollbarOverMut = 0.18; -- Used for multiply size of scrollbar when overscrolling
|
local scrollbarOverMut = 0.18; -- Used for multiply size of scrollbar when overscrolling
|
||||||
|
|
||||||
-- tween for moving
|
-- tween for moving
|
||||||
|
|
@ -148,7 +146,7 @@ function scrollFrame:render(props)
|
||||||
if inputType == mouseButton1 or inputType == touch then
|
if inputType == mouseButton1 or inputType == touch then
|
||||||
local position = input.Position;
|
local position = input.Position;
|
||||||
local x = position.X;
|
local x = position.X;
|
||||||
local y = position.Y;
|
local y = position.Y + 36;
|
||||||
self:update(self._targetX + ((x - upX) * mouseUpMut),self._targetY + ((- y + upY)*mouseUpMut));
|
self:update(self._targetX + ((x - upX) * mouseUpMut),self._targetY + ((- y + upY)*mouseUpMut));
|
||||||
mouseConnection:disconnect();
|
mouseConnection:disconnect();
|
||||||
self:fit();
|
self:fit();
|
||||||
|
|
@ -157,7 +155,7 @@ function scrollFrame:render(props)
|
||||||
mouseConnection:add(inputChanged:Connect(function (input)
|
mouseConnection:add(inputChanged:Connect(function (input)
|
||||||
if input.UserInputType == mouseMovement then
|
if input.UserInputType == mouseMovement then
|
||||||
local position = input.Position;
|
local position = input.Position;
|
||||||
local x,y = position.X,position.Y;
|
local x,y = position.X,position.Y + 36;
|
||||||
|
|
||||||
self:update(lastX + (downX - x),lastY + (downY - y));
|
self:update(lastX + (downX - x),lastY + (downY - y));
|
||||||
upX,upY = x,y;
|
upX,upY = x,y;
|
||||||
|
|
@ -232,6 +230,7 @@ function scrollFrame:update(x,y)
|
||||||
local objectAbsSize = self.__object.AbsoluteSize;
|
local objectAbsSize = self.__object.AbsoluteSize;
|
||||||
local holderX,holderY = holderAbsSize.X,holderAbsSize.Y;
|
local holderX,holderY = holderAbsSize.X,holderAbsSize.Y;
|
||||||
local objectX,objectY = objectAbsSize.X,objectAbsSize.Y;
|
local objectX,objectY = objectAbsSize.X,objectAbsSize.Y;
|
||||||
|
holderX,holderY = max(holderX,objectX),max(holderY,objectY);
|
||||||
local maxX = holderX - objectX;
|
local maxX = holderX - objectX;
|
||||||
local maxY = holderY - objectY;
|
local maxY = holderY - objectY;
|
||||||
|
|
||||||
|
|
@ -278,8 +277,9 @@ function scrollFrame:fit()
|
||||||
local holder = self._holder;
|
local holder = self._holder;
|
||||||
local holderAbsoluteSize = holder.AbsoluteSize;
|
local holderAbsoluteSize = holder.AbsoluteSize;
|
||||||
local objectAbsSize = self.__object.AbsoluteSize;
|
local objectAbsSize = self.__object.AbsoluteSize;
|
||||||
local maxX = holderAbsoluteSize.X - objectAbsSize.X;
|
local objectX,objectY = objectAbsSize.X,objectAbsSize.Y;
|
||||||
local maxY = holderAbsoluteSize.Y - objectAbsSize.Y;
|
local maxX = max(holderAbsoluteSize.X,objectX) - objectX;
|
||||||
|
local maxY = max(holderAbsoluteSize.Y,objectY) - objectY;
|
||||||
if targetX<0 or targetY<0 or targetX>maxX or targetY>maxY then
|
if targetX<0 or targetY<0 or targetX>maxX or targetY>maxY then
|
||||||
self:update(
|
self:update(
|
||||||
max(min(targetX,maxX),0),
|
max(min(targetX,maxX),0),
|
||||||
|
|
@ -310,13 +310,13 @@ function scrollFrame:updateScrollbar(x,y,objectX,objectY,holderX,holderY,elastic
|
||||||
local holderSize;
|
local holderSize;
|
||||||
if not holderY then
|
if not holderY then
|
||||||
holderSize = self._holder.AbsoluteSize;
|
holderSize = self._holder.AbsoluteSize;
|
||||||
holderY = holderSize.Y;
|
holderY = max(holderSize.Y,objectY);
|
||||||
end
|
end
|
||||||
if not holderX then
|
if not holderX then
|
||||||
if not holderSize then
|
if not holderSize then
|
||||||
holderSize = self._holder.AbsoluteSize;
|
holderSize = self._holder.AbsoluteSize;
|
||||||
end
|
end
|
||||||
holderX = holderSize.X;
|
holderX = max(holderSize.X,objectX);
|
||||||
end
|
end
|
||||||
|
|
||||||
elastic = elastic or self.Elastic;
|
elastic = elastic or self.Elastic;
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,11 @@ function module.init(shared)
|
||||||
typefunc = typefunc or type(func);
|
typefunc = typefunc or type(func);
|
||||||
local self;
|
local self;
|
||||||
if typefunc == "table" then
|
if typefunc == "table" then
|
||||||
self = func.self;
|
local t = func;
|
||||||
func = func.func;
|
self = t.self;
|
||||||
|
func = t.func;
|
||||||
|
if not self then self = t[1]; end
|
||||||
|
if not func then func = t[2]; end
|
||||||
end
|
end
|
||||||
-- check prefix
|
-- check prefix
|
||||||
if key:sub(1,prefixLen) ~= prefix then
|
if key:sub(1,prefixLen) ~= prefix then
|
||||||
|
|
|
||||||
|
|
@ -68,21 +68,21 @@ function LerpProperties(Item,Old,New,Alpha)
|
||||||
Item[Property] = Lerp(OldValue,NewValue,Alpha)
|
Item[Property] = Lerp(OldValue,NewValue,Alpha)
|
||||||
elseif Type == "UDim2" then
|
elseif Type == "UDim2" then
|
||||||
Item[Property] = UDim2.new(
|
Item[Property] = UDim2.new(
|
||||||
Lerp(OldValue.X.Scale ,NewValue.X.Scale ,Alpha),
|
Lerp(OldValue.X.Scale or 0,NewValue.X.Scale or 0,Alpha),
|
||||||
Lerp(OldValue.X.Offset,NewValue.X.Offset,Alpha),
|
Lerp(OldValue.X.Offset or 0,NewValue.X.Offset or 0,Alpha),
|
||||||
Lerp(OldValue.Y.Scale ,NewValue.Y.Scale ,Alpha),
|
Lerp(OldValue.Y.Scale or 0,NewValue.Y.Scale or 0,Alpha),
|
||||||
Lerp(OldValue.Y.Offset,NewValue.Y.Offset,Alpha)
|
Lerp(OldValue.Y.Offset or 0,NewValue.Y.Offset or 0,Alpha)
|
||||||
)
|
)
|
||||||
elseif Type == "UDim" then
|
elseif Type == "UDim" then
|
||||||
Item[Property] = UDim.new(
|
Item[Property] = UDim.new(
|
||||||
Lerp(OldValue.Scale ,NewValue.Scale ),
|
Lerp(OldValue.Scale or 0,NewValue.Scale or 0,Alpha),
|
||||||
Lerp(OldValue.Offset,NewValue.Offset)
|
Lerp(OldValue.Offset or 0,NewValue.Offset or 0,Alpha)
|
||||||
)
|
)
|
||||||
elseif Type == "Color3" then
|
elseif Type == "Color3" then
|
||||||
Item[Property] = Color3.fromRGB(
|
Item[Property] = Color3.fromRGB(
|
||||||
Lerp(OldValue.r*255,NewValue.r*255),
|
Lerp((OldValue.r or 0)*255,(NewValue.r or 0)*255,Alpha),
|
||||||
Lerp(OldValue.g*255,NewValue.g*255),
|
Lerp((OldValue.g or 0)*255,(NewValue.g or 0)*255,Alpha),
|
||||||
Lerp(OldValue.b*255,NewValue.b*255)
|
Lerp((OldValue.b or 0)*255,(NewValue.b or 0)*255,Alpha)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue