test
This commit is contained in:
parent
468aad896f
commit
f3881af24f
2 changed files with 42 additions and 6 deletions
|
|
@ -22,6 +22,7 @@ frame.BorderSizePixel = 0;
|
||||||
local button = class "TextButton";
|
local button = class "TextButton";
|
||||||
button.BorderSizePixel = 0;
|
button.BorderSizePixel = 0;
|
||||||
button.Text = nil;
|
button.Text = nil;
|
||||||
|
local image = class "ImageLabel";
|
||||||
|
|
||||||
-- tween for moving
|
-- tween for moving
|
||||||
local out = advancedTween.EasingDirections.Out;
|
local out = advancedTween.EasingDirections.Out;
|
||||||
|
|
@ -80,8 +81,12 @@ function scrollFrame:init(props)
|
||||||
props:default("ZIndex",1);
|
props:default("ZIndex",1);
|
||||||
props:default("BackgroundColor3",white);
|
props:default("BackgroundColor3",white);
|
||||||
props:default("ScrollbarSizeX",2);
|
props:default("ScrollbarSizeX",2);
|
||||||
|
props:default("ScrollbarVisibleY",false);
|
||||||
|
props:default("ScrollbarSizeX",2);
|
||||||
|
props:default("ScrollbarVisibleX",true);
|
||||||
props:default("ScrollbarPadding",2);
|
props:default("ScrollbarPadding",2);
|
||||||
props:default("ScrollbarVisible",true);
|
props:default("ScrollbarColor3",Color3.fromRGB(172, 172, 172));
|
||||||
|
props:default("ScrollbarTransparency",0.5);
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Render objects
|
-- Render objects
|
||||||
|
|
@ -95,7 +100,7 @@ function scrollFrame:render(props)
|
||||||
ClipsDescendants = true;
|
ClipsDescendants = true;
|
||||||
[event.createdSync] = function (this)
|
[event.createdSync] = function (this)
|
||||||
this.InputChanged:Connect(function (input)
|
this.InputChanged:Connect(function (input)
|
||||||
if self._mouseDown then
|
if self._mouseDown or self._scrollbarDown then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
local inputType = input.UserInputType;
|
local inputType = input.UserInputType;
|
||||||
|
|
@ -157,9 +162,22 @@ function scrollFrame:render(props)
|
||||||
self._holder = this;
|
self._holder = this;
|
||||||
end;
|
end;
|
||||||
};
|
};
|
||||||
-- button {
|
button {
|
||||||
|
Visible = props "ScrollbarVisibleY";
|
||||||
-- }
|
Size = props "ScrollbarPadding,ScrollbarSizeX":with(function (store)
|
||||||
|
self:fit();
|
||||||
|
end);
|
||||||
|
image {
|
||||||
|
roundSize = 2000;
|
||||||
|
ImageColor3 = props "ScrollbarColor3";
|
||||||
|
ImageTransparency = props "ScrollbarTransparency";
|
||||||
|
Size = props "ScrollbarSizeX,ScrollbarPadding":with(function (store)
|
||||||
|
return UDim2.new(0,store.ScrollbarSizeX,1,store.ScrollbarPadding * 2);
|
||||||
|
end);
|
||||||
|
Position = UDim2.fromScale(0.5,0.5);
|
||||||
|
AnchorPoint = Vector2.new(0.5,0.5);
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -183,6 +201,7 @@ function scrollFrame:update(x,y)
|
||||||
Position = UDim2.fromOffset(x,-y);
|
Position = UDim2.fromOffset(x,-y);
|
||||||
});
|
});
|
||||||
self._targetX,self._targetY = x,y;
|
self._targetX,self._targetY = x,y;
|
||||||
|
self:updateScrollbar(x,y);
|
||||||
return inputIndex;
|
return inputIndex;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -215,6 +234,8 @@ function scrollFrame:fit()
|
||||||
max(min(targetX,maxX),0),
|
max(min(targetX,maxX),0),
|
||||||
max(min(targetY,maxY),0)
|
max(min(targetY,maxY),0)
|
||||||
);
|
);
|
||||||
|
else
|
||||||
|
self:updateScrollbar(targetX,targetY);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,12 @@ function module.init(shared)
|
||||||
((type(object) == "table" and object.__object) or object):GetPropertyChangedSignal "ClassName":Connect(function()
|
((type(object) == "table" and object.__object) or object):GetPropertyChangedSignal "ClassName":Connect(function()
|
||||||
return self;
|
return self;
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
--after render
|
||||||
|
local afterRender = this.afterRender;
|
||||||
|
if afterRender then
|
||||||
|
afterRender(self,object);
|
||||||
|
end
|
||||||
return self;
|
return self;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -239,10 +245,12 @@ function module.init(shared)
|
||||||
if lastObject then
|
if lastObject then
|
||||||
lastObject.Parent = nil;
|
lastObject.Parent = nil;
|
||||||
end
|
end
|
||||||
|
|
||||||
object = self:render(self.__prop); -- new instance
|
object = self:render(self.__prop); -- new instance
|
||||||
rawset(self,"__holder",object);
|
rawset(self,"__holder",object);
|
||||||
rawset(self,"__object",object);
|
rawset(self,"__object",object);
|
||||||
object.Parent = getHolder(parent); -- update parent
|
object.Parent = getHolder(parent); -- update parent
|
||||||
|
|
||||||
-- restore childs
|
-- restore childs
|
||||||
local child = rawget(self,"__child");
|
local child = rawget(self,"__child");
|
||||||
if child then
|
if child then
|
||||||
|
|
@ -252,6 +260,7 @@ function module.init(shared)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- prevnet gc
|
-- prevnet gc
|
||||||
((type(object) == "table" and object.__object) or object):GetPropertyChangedSignal "ClassName":Connect(function()
|
((type(object) == "table" and object.__object) or object):GetPropertyChangedSignal "ClassName":Connect(function()
|
||||||
return self;
|
return self;
|
||||||
|
|
@ -259,6 +268,12 @@ function module.init(shared)
|
||||||
if lastObject then -- remove old instance
|
if lastObject then -- remove old instance
|
||||||
self:Destroy(lastObject);
|
self:Destroy(lastObject);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--after render
|
||||||
|
local afterRender = this.afterRender;
|
||||||
|
if afterRender then
|
||||||
|
afterRender(self,object);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- define destroy method
|
-- define destroy method
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue