【优化】scrollview setData不是回到顶部时不再播放动画

dev_chengFeng
JieLing 2020-12-30 16:45:52 +08:00
parent ef3c269876
commit e8ea367a6e
8 changed files with 28 additions and 43 deletions

View File

@ -81,10 +81,8 @@ function this.RefreshRankInfo(isTop)
end
end
-- 重置排行列表
this.ScrollView:SetData(rankList, rankAdapterFunc)
if isTop then -- 判断是否滚动到最上面
this.ScrollView:SetIndex(1)
end
this.ScrollView:SetData(rankList, rankAdapterFunc, not isTop)
-- 我的排名
--this.RankNodeAdapter(this.myRankItem, myRankInfo)
local rankStr = myRankInfo.personInfo.rank

View File

@ -140,14 +140,11 @@ function this.OnShowMailListData(_allMail, isTop)
this.mialNum.text=Language[11147]..maildataCount
this.ScrollView:SetData(allMail, function (index, go)
this.SingleMialDataShow(go, allMail[index])
end)
end, not isTop)
-- if isPlayAnim then
-- SecTorPlayAnimByScroll(this.ScrollView)
-- isPlayAnim = false
-- end
if isTop then
this.ScrollView:SetIndex(1)
end
end
function this.SingleMialDataShow(_go,_mailData)
local mailImage = Util.GetGameObject(_go.transform, "mailImage")

View File

@ -56,14 +56,11 @@ function this.OnShowPanelData(isTop)
this.RewardTabsSort(AllData)
this.ScrollView:SetData(AllData, function (index, go)
this.SingleDataShow(go, AllData[index])
end)
end, not isTop)
-- if isPlayAnim then
-- SecTorPlayAnimByScroll(this.ScrollView)
-- isPlayAnim = false
-- end
if isTop then
this.ScrollView:SetIndex(1)
end
end
function this.SingleDataShow(go,rewardData)

View File

@ -118,15 +118,12 @@ function this.OnShowData(isTop)
local AllData = TaskManager.GetTypeTaskList(TaskTypeDef.Achievement)
this.ScrollView:SetData(curDailyMissionData, function (index, go)
this.SingleMissionDatasDataShow(go,curDailyMissionData[index])
end)
end, not isTop)
this.SetDailyMissionBox(curDailyMissionBoxData)
-- if isPlayAnim then
-- SecTorPlayAnimByScroll(this.ScrollView)
-- isPlayAnim = false
-- end
if isTop then
this.ScrollView:SetIndex(1)
end
end

View File

@ -88,10 +88,7 @@ function WeekMonthGiftPackPage:RefreshGiftData(isTop)
local callBack = function(index, item)
self:RefreshShowData(item, shopData[index].data)
end
self.scrollView:SetData(shopData, callBack)
if isTop then
self.scrollView:SetIndex(1)
end
self.scrollView:SetData(shopData, callBack, not isTop)
if isPlayAnim then
SecTorPlayAnimByScroll(self.scrollView)
isPlayAnim = false

View File

@ -160,7 +160,7 @@ function this.SetWarPowerInfo()
return
end
this.SetHeadsInfo(warPowerData[index],root,index,warPowerData[index].userName,warPowerData[index].level)
end)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
@ -193,7 +193,7 @@ function this.SetArenaInfo()
return
end
this.SetHeadsInfo(arenaData[index].personInfo,root,index,arenaData[index].personInfo.name,arenaData[index].personInfo.level)
end)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
@ -236,7 +236,7 @@ function this.SetTrialInfo()
return
end
this.SetHeadsInfo(trialData[index],root,index,trialData[index].userName,trialData[index].level)
end)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
@ -265,7 +265,7 @@ function this.SetMonsterInfo()
return
end
this.SetHeadsInfo(monsterData[index],root,index,monsterData[index].userName,monsterData[index].level)
end)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
@ -297,7 +297,7 @@ function this.SetAdventureInfo()
return
end
this.SetHeadsInfo(adventureData[index],root,index,adventureData[index].name,adventureData[index].level)
end)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
@ -333,7 +333,7 @@ function this.SetCustomsPassInfo()
return
end
this.SetHeadsInfo(data[index],root,index,data[index].userName,data[index].level)
end)
end, not this.istop)
this.CheckIsTop()
end
--显示每条数据
@ -487,8 +487,9 @@ end
--检查是否显示第一页 当切换页签时切换到第一页 当请求下一页时不跳转第一页
function this.CheckIsTop()
if this.istop then
this.scrollView:SetIndex(1)
-- this.scrollView:SetIndex(1)
this.istop =false
end
end
--检查Tab是否解锁

View File

@ -4,7 +4,7 @@ local this = ScrollCycleView
local reverse = table.reverse
local function playGoAnim(self, go)
if self.isPlayAnim then
if self.isTop and self.isPlayAnim then
go.transform.localScale = Vector3.zero
go.transform:DOScale(Vector3.one*1, 0.2)
end
@ -274,6 +274,7 @@ function this:SetData(dataList, updateFunc, noTop, noAnim)
self.updateFunc = updateFunc --刷新回调,返回数据列表的索引和对应预设
self.dataCount = #dataList
self.isPlayAnim = not noAnim
self.isTop = not noTop
if self.dragType == 1 then
self.itemDis = self.itemHeight * math.ceil(self.dataCount / self.fixedCount) + self.spacing.y - self.rectTransform.sizeDelta.y
@ -291,11 +292,11 @@ function this:SetData(dataList, updateFunc, noTop, noAnim)
end
-- 判断是否回到顶部,否则保持不动
if noTop then
if self.isTop then
self:SetShow(1)
else
local showIndex = self:CalShowIndex()
self:SetShow(showIndex)
else
self:SetShow(1)
end
end
@ -331,10 +332,13 @@ function this:SetShow(showIndex)
-- 隐藏所有物体,并处理物体在数据结构中的位置
for j=1, self.fixedCount do
for i=1, self.itemCount do
local item = self.cellItemList[j][i]
if item.go then
item.isActive = false
item.go:SetActive(false)
-- 回到最上面的时候
if self.isTop then
local item = self.cellItemList[j][i]
if item.go then
item.isActive = false
item.go:SetActive(false)
end
end
end
move(self.cellItemList[j], oldLine - self.dataLine)

View File

@ -390,10 +390,7 @@ function this:RefreshItemList(isTop)
-- if isPlayShow then
-- shopItem.gameObject:SetActive(false)
-- end
end)
if isTop then
self.RechargeScrollView:SetIndex(1)
end
end, not isTop)
-- if isPlayShow then
-- SecTorPlayAnimByScroll(self.RechargeScrollView,0.03)
-- isPlayShow = false
@ -409,10 +406,7 @@ function this:RefreshItemList(isTop)
if isPlayShow then
shopItem.gameObject:SetActive(true)
end
end)
if isTop then
self.ScrollView:SetIndex(1)
end
end, not isTop)
-- if isPlayShow then
-- -- SecTorPlayAnimByScroll(self.ScrollView, 0.03)
-- isPlayShow = false