滑动 回弹修改提交

dev_chengFeng
jiaoyangna 2021-08-06 11:29:06 +08:00
parent 360cbbf54f
commit 5cf3388a59
1 changed files with 8 additions and 4 deletions

View File

@ -78,7 +78,7 @@ local function SetItemIndex(self, curIndex)
end end
end end
local function SetPosition(self, dv2) local function SetPosition(self, dv2,isBack)
local av2 = self.dragGOTran.anchoredPosition local av2 = self.dragGOTran.anchoredPosition
if self.dragType == 1 then if self.dragType == 1 then
dv2.x = 0 dv2.x = 0
@ -92,12 +92,16 @@ local function SetPosition(self, dv2)
if self.dragType == 1 then if self.dragType == 1 then
if fv2.y < (0 - self.maxOffSet) or fv2.y > (self.itemDis + self.maxOffSet) then if fv2.y < (0 - self.maxOffSet) or fv2.y > (self.itemDis + self.maxOffSet) then
fv2.y = math.clamp(fv2.y, 0, self.itemDis) fv2.y = math.clamp(fv2.y, 0, self.itemDis)
return if not isBack then
return
end
end end
elseif self.dragType == 2 then elseif self.dragType == 2 then
if fv2.x < (0 - self.maxOffSet) or fv2.x > (self.itemDis + self.maxOffSet) then if fv2.x < (0 - self.maxOffSet) or fv2.x > (self.itemDis + self.maxOffSet) then
fv2.x = math.clamp(-fv2.x, -self.itemDis, 0) fv2.x = math.clamp(-fv2.x, -self.itemDis, 0)
return if not isBack then
return
end
end end
end end
else else
@ -142,7 +146,7 @@ end
local function OnEndDrag(self, Pointgo, data) local function OnEndDrag(self, Pointgo, data)
if not self.isBeginDrag then return end if not self.isBeginDrag then return end
if not self.dataList then return end if not self.dataList then return end
SetPosition(self, data.delta) SetPosition(self, data.delta,true)
self.moveTween.IsUseCallBack = true self.moveTween.IsUseCallBack = true
data:Use() data:Use()
self.isBeginDrag = false self.isBeginDrag = false