【ID1009737】

【滑动界面】可上下滑动的界面设定一个滑动上限
dev_chengFeng
jiaoyangna 2021-08-04 15:36:39 +08:00
parent 8cac60fad7
commit 3f9b6be120
1 changed files with 17 additions and 6 deletions

View File

@ -87,21 +87,23 @@ local function SetPosition(self, dv2)
end
local fv2 = av2 + dv2
if not self.elastic then
--if not self.elastic then
if self.itemDis > 0 then
if self.dragType == 1 then
if fv2.y < 0 or fv2.y > self.itemDis then
if fv2.y < (0 - self.maxOffSet) or fv2.y > (self.itemDis + self.maxOffSet) then
fv2.y = math.clamp(fv2.y, 0, self.itemDis)
return
end
elseif self.dragType == 2 then
if fv2.x < 0 or fv2.x > self.itemDis then
if fv2.x < (0 - self.maxOffSet) or fv2.x > (self.itemDis + self.maxOffSet) then
fv2.x = math.clamp(-fv2.x, -self.itemDis, 0)
return
end
end
else
fv2 = Vector2.zero
return
end
end
--end
self.dragGOTran.anchoredPosition = fv2
local curIndex
@ -260,7 +262,16 @@ function ScrollCycleView:OnDestroy()
end
--界面打开时调用(用于子类重写)
function ScrollCycleView:OnOpen(itemGO, scrollBar, scrollSizeDeltaV2, dragType, fixedCount, spacingV2)
function ScrollCycleView:OnOpen(itemGO, scrollBar, scrollSizeDeltaV2, dragType, fixedCount, spacingV2,maxOffSet)
if not maxOffSet then
if not self.elastic then
self.maxOffSet = 0
else
self.maxOffSet = 500
end
else
self.maxOffSet = maxOffSet
end
self.gameObject:SetActive(true)
self.item = itemGO --关联的预设
self.scrollBar = scrollBar --关联scrollBar组件