fixed tween udim and other type issue

This commit is contained in:
세젤귀 고양이들 2022-02-20 23:39:48 +09:00
parent 58821a6921
commit 341e9d5d7b
3 changed files with 28 additions and 25 deletions

View file

@ -17,14 +17,12 @@ local image = class "ImageLabel";
image.BackgroundTransparency = 1;
-- const
local white = Color3.fromRGB(255,255,255);
local scrollMut = 100; -- Used for multiply input when using mosue scroll
local elasticMut = 20; -- Used for multiply input when overscrolling
local fitTime = 0.22; -- Used for reset overscroll when mouse scroll
local tweenTime = 0.63; -- Used for tween time
local mouseUpMut = 18; -- 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 white = Color3.fromRGB(255,255,255);
local scrollMut = 100; -- Used for multiply input when using mosue scroll
local elasticMut = 18; -- Used for multiply input when overscrolling
local fitTime = 0.26; -- Used for reset overscroll when mouse scroll
local tweenTime = 0.71; -- Used for tween time
local mouseUpMut = 6; -- Used for multiply input when drag input ended
local scrollbarOverMut = 0.18; -- Used for multiply size of scrollbar when overscrolling
-- tween for moving
@ -148,7 +146,7 @@ function scrollFrame:render(props)
if inputType == mouseButton1 or inputType == touch then
local position = input.Position;
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));
mouseConnection:disconnect();
self:fit();
@ -157,7 +155,7 @@ function scrollFrame:render(props)
mouseConnection:add(inputChanged:Connect(function (input)
if input.UserInputType == mouseMovement then
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));
upX,upY = x,y;
@ -232,6 +230,7 @@ function scrollFrame:update(x,y)
local objectAbsSize = self.__object.AbsoluteSize;
local holderX,holderY = holderAbsSize.X,holderAbsSize.Y;
local objectX,objectY = objectAbsSize.X,objectAbsSize.Y;
holderX,holderY = max(holderX,objectX),max(holderY,objectY);
local maxX = holderX - objectX;
local maxY = holderY - objectY;
@ -278,8 +277,9 @@ function scrollFrame:fit()
local holder = self._holder;
local holderAbsoluteSize = holder.AbsoluteSize;
local objectAbsSize = self.__object.AbsoluteSize;
local maxX = holderAbsoluteSize.X - objectAbsSize.X;
local maxY = holderAbsoluteSize.Y - objectAbsSize.Y;
local objectX,objectY = objectAbsSize.X,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
self:update(
max(min(targetX,maxX),0),
@ -310,13 +310,13 @@ function scrollFrame:updateScrollbar(x,y,objectX,objectY,holderX,holderY,elastic
local holderSize;
if not holderY then
holderSize = self._holder.AbsoluteSize;
holderY = holderSize.Y;
holderY = max(holderSize.Y,objectY);
end
if not holderX then
if not holderSize then
holderSize = self._holder.AbsoluteSize;
end
holderX = holderSize.X;
holderX = max(holderSize.X,objectX);
end
elastic = elastic or self.Elastic;

View file

@ -38,8 +38,11 @@ function module.init(shared)
typefunc = typefunc or type(func);
local self;
if typefunc == "table" then
self = func.self;
func = func.func;
local t = func;
self = t.self;
func = t.func;
if not self then self = t[1]; end
if not func then func = t[2]; end
end
-- check prefix
if key:sub(1,prefixLen) ~= prefix then

View file

@ -68,21 +68,21 @@ function LerpProperties(Item,Old,New,Alpha)
Item[Property] = Lerp(OldValue,NewValue,Alpha)
elseif Type == "UDim2" then
Item[Property] = UDim2.new(
Lerp(OldValue.X.Scale ,NewValue.X.Scale ,Alpha),
Lerp(OldValue.X.Offset,NewValue.X.Offset,Alpha),
Lerp(OldValue.Y.Scale ,NewValue.Y.Scale ,Alpha),
Lerp(OldValue.Y.Offset,NewValue.Y.Offset,Alpha)
Lerp(OldValue.X.Scale or 0,NewValue.X.Scale or 0,Alpha),
Lerp(OldValue.X.Offset or 0,NewValue.X.Offset or 0,Alpha),
Lerp(OldValue.Y.Scale or 0,NewValue.Y.Scale or 0,Alpha),
Lerp(OldValue.Y.Offset or 0,NewValue.Y.Offset or 0,Alpha)
)
elseif Type == "UDim" then
Item[Property] = UDim.new(
Lerp(OldValue.Scale ,NewValue.Scale ),
Lerp(OldValue.Offset,NewValue.Offset)
Lerp(OldValue.Scale or 0,NewValue.Scale or 0,Alpha),
Lerp(OldValue.Offset or 0,NewValue.Offset or 0,Alpha)
)
elseif Type == "Color3" then
Item[Property] = Color3.fromRGB(
Lerp(OldValue.r*255,NewValue.r*255),
Lerp(OldValue.g*255,NewValue.g*255),
Lerp(OldValue.b*255,NewValue.b*255)
Lerp((OldValue.r or 0)*255,(NewValue.r or 0)*255,Alpha),
Lerp((OldValue.g or 0)*255,(NewValue.g or 0)*255,Alpha),
Lerp((OldValue.b or 0)*255,(NewValue.b or 0)*255,Alpha)
)
end
end