【ID1017608】

【点将台】点击箭头,当切换页面大于2个时,会出现明显未对准后校准状态
dev_chengFeng
jiaoyangna 2021-08-03 12:03:07 +08:00
parent 0de6e3f63a
commit fabd517c04
2 changed files with 76 additions and 49 deletions

View File

@ -110,7 +110,7 @@ function ElementDrawCardPanelNew:BindEvent()
end
function ElementDrawCardPanelNew:BtnAction(index)
LogGreen("index:"..index)
--LogGreen("index:"..index)
if not index or index < 1 or index > 4 then
return
end

View File

@ -7,7 +7,7 @@ local _CurPageIndex = 0
local orginLayer
local redPointTypeList = {}
local subViewList = {}
local isEnter = 0
local isEnter = 0 --是否开始拖动
local lastIndex = 0
--初始化组件(用于子类重写)
function RecruitMainPanel:InitComponent()
@ -35,29 +35,9 @@ function RecruitMainPanel:InitComponent()
this.moveWidth = this.grid:GetComponent("RectTransform").rect.width
this.itemWidth = this.item:GetComponent("RectTransform").rect.width
this.off = 51
-- for i = 1,this.count do
-- if not this.itemList[i] then
-- this.itemList[i] = {}
-- this.itemList[i].go = newObjToParent(this.item,this.grid)
-- this.itemList[i].go.name = "tab_"..i
-- this.itemList[i].tran = this.itemList[i].go:GetComponent("RectTransform")
-- local vec = this.itemList[i].tran.anchoredPosition
-- vec.x = this.off * (i - 1) + i * this.itemWidth
-- vec.y = 0
-- this.itemList[i].tran.anchoredPosition = vec
-- this.itemList[i].pos = this.itemList[i].tran.anchoredPosition
-- this.itemList[i].index = i
-- this.itemList[i].img = Util.GetGameObject(this.itemList[i].go, "img"):GetComponent("Image")
-- this.itemList[i].redpot = Util.GetGameObject(this.itemList[i].go, "redpot")
-- end
-- end
this.pos0 = Vector3.New(this.off * (0 - 2) + (0 - 1) * this.itemWidth - 30,50,0)
--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()
@ -78,7 +58,7 @@ function this.SortItemList()
end)
end
---设置位置
---设置拖动左右方向
function this.SetPos(v2)
if isEnter == 1 then
if v2.x > 2 then
@ -96,6 +76,7 @@ function this.MoveTo(LOR,func)
end
this.select.gameObject:SetActive(false)
for i = 1,#this.itemList do
this.itemList[i].move = true
local targetPos = ""
if LOR == 2 then
if i + 1 > #this.itemList then
@ -112,13 +93,15 @@ function this.MoveTo(LOR,func)
targetPos = i - 1
end
end
local targetPos1 = this.itemList[targetPos].pos
local targetPos1 = this.itemList[targetPos].pos
this.itemList[i].go.transform:DOAnchorPos(targetPos1, 0.2, false)
:OnStart(function() end)
:OnStart(function()
end)
:OnUpdate(function()end)
:OnComplete(function ()
this.itemList[i].index = targetPos
this.itemList[i].pos = targetPos1
this.itemList[i].move = false
if func then
func()
end
@ -143,23 +126,33 @@ function this.OnEndDrag(Pointgo, data)
local ro = isEnter
isEnter = 1
this.mask:SetActive(true)
local localIsenter = false
this.RemoveTrigger()
this.thread1 = coroutine.start(function()
this.RemoveTrigger()
coroutine.wait(0.01)
this.MoveTo(ro)
coroutine.wait(0.25)
this.SortItemList()
coroutine.wait(0.01)
this.MoveTo(ro)
--coroutine.wait(0.2/(this.itemWidth + this.off))
while(not localIsenter) do
local isfinish = true
for j = 1,#this.itemList do
if this.itemList[j].move then
isfinish = false
break
end
end
if isfinish then
localIsenter = true
end
coroutine.wait(0.2/(this.itemWidth + this.off))
end
this.SortItemList()
if ro == 2 then
this:RightAction()
elseif ro == 3 then
this:LeftAction()
end
coroutine.wait(0.01)
this.mask:SetActive(false)
this.AddTrigger()
isEnter = 0
coroutine.yield()
end)
end
@ -170,31 +163,56 @@ function RecruitMainPanel:BindEvent()
this:ClosePanel()
end)
Util.AddClick(this.leftBtn, function()
local localIsenter = false
this.mask:SetActive(true)
this.RemoveTrigger()
self.thread = coroutine.start(function()
coroutine.wait(0.01)
this.MoveTo(3)
coroutine.wait(0.25)
--coroutine.wait(0.2/(this.itemWidth + this.off))
while(not localIsenter) do
local isfinish = true
for j = 1,#this.itemList do
if this.itemList[j].move then
isfinish = false
break
end
end
if isfinish then
localIsenter = true
end
coroutine.wait(0.2/(this.itemWidth + this.off))
end
this.SortItemList()
coroutine.wait(0.01)
this:LeftAction()
this.mask:SetActive(false)
this.AddTrigger()
this.AddTrigger()
end)
end)
Util.AddClick(this.rightBtn, function()
local localIsenter = false
this.mask:SetActive(true)
this.RemoveTrigger()
self.thread = coroutine.start(function()
coroutine.wait(0.01)
this.MoveTo(2)
coroutine.wait(0.25)
--coroutine.wait(0.2/(this.itemWidth + this.off))
while(not localIsenter) do
local isfinish = true
for j = 1,#this.itemList do
if this.itemList[j].move then
isfinish = false
break
end
end
if isfinish then
localIsenter = true
end
coroutine.wait(0.2/(this.itemWidth + this.off))
end
this.SortItemList()
coroutine.wait(0.01)
this:RightAction()
this.mask:SetActive(false)
this.AddTrigger()
coroutine.yield()
end)
end)
@ -361,6 +379,7 @@ function this:RefreshTabData()
else
if not this.itemList[i] then
this.itemList[i] = {}
this.itemList[i].move = false
this.itemList[i].go = newObjToParent(this.item,this.grid)
this.itemList[i].go.name = "tab_"..i
this.itemList[i].tran = this.itemList[i].go:GetComponent("RectTransform")
@ -368,7 +387,6 @@ function this:RefreshTabData()
vec.x = this.off * (i - 2) + (i - 1) * this.itemWidth - 30
vec.y = 50
this.itemList[i].tran.anchoredPosition = vec
--LogGreen("vec:"..i.." "..tostring(vec))
this.itemList[i].pos = this.itemList[i].tran.anchoredPosition
this.itemList[i].index = i
this.itemList[i].img = Util.GetGameObject(this.itemList[i].go, "img"):GetComponent("Image")
@ -382,7 +400,6 @@ function this:RefreshTabData()
end
end
this.pos4 = Vector3.New(this.off * (#this.itemList - 1) + (#this.itemList) * this.itemWidth - 30,50,0)
--LogGreen("this.pos4:"..tostring(this.pos4))
end
function this:SetIndex()
@ -408,14 +425,24 @@ function this:SetIndex()
if localIsenter then
localIsenter = false
this.MoveTo(LOY)
coroutine.wait(0.25)
offSet = offSet - 1
this.SortItemList()
coroutine.wait(0.01)
localIsenter = true
--coroutine.wait(0.2/(this.itemWidth + this.off))
while(not localIsenter) do
local isfinish = true
for j = 1,#this.itemList do
if this.itemList[j].move then
isfinish = false
break
end
end
if isfinish then
offSet = offSet - 1
this.SortItemList()
localIsenter = true
end
coroutine.wait(0.2/(this.itemWidth + this.off))
end
end
coroutine.wait(0.01)
end
end
this:RefreshJianTou()
this.AddTrigger()
this:PageOnChange(true)