滑动修改提交
parent
1e80b80c82
commit
5cac652fa3
|
@ -56,18 +56,17 @@ function RecruitMainPanel:InitComponent()
|
|||
--LogGreen("this.pos0:"..tostring(this.pos0))
|
||||
--this.pos4 = Vector3.New(this.off * (4 - 1) + 4 * this.itemWidth,0,0)
|
||||
self.lastPage,self.curPage,self.nextPage = 0,0,0
|
||||
this.trigger = Util.GetEventTriggerListener(this.gameObject) --触摸事件
|
||||
this.AddTrigger()
|
||||
end
|
||||
|
||||
function this.RemoveTrigger()
|
||||
this.trigger = Util.GetEventTriggerListener(this.gameObject) --触摸事件
|
||||
function this.RemoveTrigger()
|
||||
this.trigger.onBeginDrag = this.trigger.onBeginDrag - this.OnBeginDrag
|
||||
this.trigger.onDrag = this.trigger.onDrag - this.OnDrag
|
||||
this.trigger.onEndDrag = this.trigger.onEndDrag - this.OnEndDrag
|
||||
end
|
||||
|
||||
function this.AddTrigger()
|
||||
this.trigger = Util.GetEventTriggerListener(this.gameObject) --触摸事件
|
||||
this.trigger.onBeginDrag = this.trigger.onBeginDrag + this.OnBeginDrag
|
||||
this.trigger.onDrag = this.trigger.onDrag + this.OnDrag
|
||||
this.trigger.onEndDrag = this.trigger.onEndDrag + this.OnEndDrag
|
||||
|
@ -80,24 +79,21 @@ function this.SortItemList()
|
|||
end
|
||||
|
||||
---设置位置
|
||||
function this.SetPos(v2)
|
||||
if isEnter == 1 then
|
||||
function this.SetPos(v2)
|
||||
if isEnter == 1 then
|
||||
if v2.x > 2 then
|
||||
isEnter = 0 --右
|
||||
this.MoveTo(2,function()
|
||||
isEnter = 2
|
||||
end)
|
||||
isEnter = 2 --右
|
||||
elseif v2.x < -2 then
|
||||
isEnter = 0 --左
|
||||
this.MoveTo(3,function()
|
||||
isEnter = 3
|
||||
end)
|
||||
isEnter = 3 --左
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---手指拖动结束 ui归位
|
||||
function this.MoveTo(LOR,func)
|
||||
if LOR < 2 then
|
||||
return
|
||||
end
|
||||
this.select.gameObject:SetActive(false)
|
||||
for i = 1,#this.itemList do
|
||||
local targetPos = ""
|
||||
|
@ -136,21 +132,35 @@ function this.OnBeginDrag(Pointgo, data)
|
|||
end
|
||||
end
|
||||
function this.OnDrag(Pointgo, data)
|
||||
this.SetPos(data.delta)
|
||||
if isEnter == 1 then
|
||||
this.SetPos(data.delta)
|
||||
end
|
||||
end
|
||||
function this.OnEndDrag(Pointgo, data)
|
||||
Timer.New(function()
|
||||
if isEnter == 2 or isEnter == 3 then
|
||||
--this.SetPos(data.delta)
|
||||
this.SortItemList()
|
||||
if isEnter == 2 then
|
||||
this:RightAction()
|
||||
elseif isEnter == 3 then
|
||||
this:LeftAction()
|
||||
end
|
||||
isEnter = 0
|
||||
if isEnter < 1 then
|
||||
return
|
||||
end
|
||||
local ro = isEnter
|
||||
isEnter = 1
|
||||
this.mask:SetActive(true)
|
||||
this.thread1 = coroutine.start(function()
|
||||
this.RemoveTrigger()
|
||||
coroutine.wait(0.01)
|
||||
this.MoveTo(ro)
|
||||
coroutine.wait(0.25)
|
||||
this.SortItemList()
|
||||
coroutine.wait(0.1)
|
||||
if ro == 2 then
|
||||
this:RightAction()
|
||||
elseif ro == 3 then
|
||||
this:LeftAction()
|
||||
end
|
||||
end,0.23):Start()
|
||||
coroutine.wait(0.01)
|
||||
this.mask:SetActive(false)
|
||||
this.AddTrigger()
|
||||
isEnter = 0
|
||||
coroutine.yield()
|
||||
end)
|
||||
end
|
||||
|
||||
--绑定事件(用于子类重写)
|
||||
|
@ -161,7 +171,8 @@ function RecruitMainPanel:BindEvent()
|
|||
end)
|
||||
Util.AddClick(this.leftBtn, function()
|
||||
this.mask:SetActive(true)
|
||||
self.thread = coroutine.start(function()
|
||||
this.RemoveTrigger()
|
||||
self.thread = coroutine.start(function()
|
||||
coroutine.wait(0.01)
|
||||
this.MoveTo(3)
|
||||
coroutine.wait(0.25)
|
||||
|
@ -169,10 +180,12 @@ function RecruitMainPanel:BindEvent()
|
|||
coroutine.wait(0.01)
|
||||
this:LeftAction()
|
||||
this.mask:SetActive(false)
|
||||
this.AddTrigger()
|
||||
end)
|
||||
end)
|
||||
Util.AddClick(this.rightBtn, function()
|
||||
this.mask:SetActive(true)
|
||||
this.RemoveTrigger()
|
||||
self.thread = coroutine.start(function()
|
||||
coroutine.wait(0.01)
|
||||
this.MoveTo(2)
|
||||
|
@ -181,11 +194,13 @@ function RecruitMainPanel:BindEvent()
|
|||
coroutine.wait(0.01)
|
||||
this:RightAction()
|
||||
this.mask:SetActive(false)
|
||||
this.AddTrigger()
|
||||
end)
|
||||
end)
|
||||
|
||||
Util.AddClick(this.jiantouyou , function()
|
||||
this.mask:SetActive(true)
|
||||
this.RemoveTrigger()
|
||||
for i = self.curPage - 1,1,-1 do
|
||||
if self.dicData[i].RpType and self.dicData[i].RpType > 0 then
|
||||
if RecruitManager.GetAllRecruitBtnRedpoint(self.dicData[i].RpType) then
|
||||
|
@ -199,10 +214,10 @@ function RecruitMainPanel:BindEvent()
|
|||
self.lastPage = self.curPage - 1 > 0 and self.curPage - 1 or #self.dicData
|
||||
self.nextPage = self.curPage + 1 > #self.dicData and 1 or self.curPage + 1
|
||||
this:SetIndex()
|
||||
this:PageOnChange(true)
|
||||
end)
|
||||
Util.AddClick(this.jiantouzuo , function()
|
||||
this.mask:SetActive(true)
|
||||
this.RemoveTrigger()
|
||||
for i = self.curPage + 1,#self.dicData,1 do
|
||||
if self.dicData[i].RpType and self.dicData[i].RpType > 0 then
|
||||
if RecruitManager.GetAllRecruitBtnRedpoint(self.dicData[i].RpType) then
|
||||
|
@ -216,7 +231,6 @@ function RecruitMainPanel:BindEvent()
|
|||
self.lastPage = self.curPage - 1 > 0 and self.curPage - 1 or #self.dicData
|
||||
self.nextPage = self.curPage + 1 > #self.dicData and 1 or self.curPage + 1
|
||||
this:SetIndex()
|
||||
this:PageOnChange(true)
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -293,6 +307,7 @@ function RecruitMainPanel:OnShow()
|
|||
self.lastPage = self.curPage - 1 > 0 and self.curPage - 1 or #self.dicData
|
||||
self.nextPage = self.curPage + 1 > #self.dicData and 1 or self.curPage + 1
|
||||
lastIndex = self.curPage
|
||||
this.RemoveTrigger()
|
||||
this:SetIndex(self.curPage)
|
||||
this:PageOnChange(false)
|
||||
end
|
||||
|
@ -351,6 +366,7 @@ function this:SetIndex()
|
|||
for i = 1,#this.itemList do
|
||||
if this.itemList[i].pageIndex == self.curPage then
|
||||
if this.itemList[i].index == 2 then
|
||||
this.AddTrigger()
|
||||
return
|
||||
else
|
||||
local LOY = 0
|
||||
|
@ -362,7 +378,6 @@ function this:SetIndex()
|
|||
local offSet = math.abs(this.itemList[i].index - 2)
|
||||
local localIsenter = true
|
||||
self.thread = coroutine.start(function()
|
||||
this.RemoveTrigger()
|
||||
while(offSet > 0) do
|
||||
if localIsenter then
|
||||
localIsenter = false
|
||||
|
@ -453,6 +468,10 @@ function RecruitMainPanel:OnClose()
|
|||
coroutine.stop(self.thread)
|
||||
self.thread = nil
|
||||
end
|
||||
if this.thread1 then
|
||||
coroutine.stop(this.thread1)
|
||||
self.thread = nil
|
||||
end
|
||||
for k,v in pairs(redPointTypeList) do
|
||||
ClearRedPointObject(k,v)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue