Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

2013.2087 widget.newScrollView scrolls to top when inserting new items
Started by iPlayalot Nov 21 2013 11:20 PM

17 replies to this topic
endless scrollview bug
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

iPlayalot

[GLOBAL: userInfoPane.html]
iPlayalot
  • Enthusiast

  • 65 posts
  • Corona SDK

a few builds ago I made an endless scrollview (like instagram - inserting new items to bottom when Reached Top Limit)

 

in this daily build; scroll goes to top 0,0 when inserting new items.

 

   -- If the scrollView has reached it's scroll limit
   if ( event.limitReached ) then
      if ( "up" == direction ) then
         print( "Reached Top Limit" )
         loadNewItems()
      elseif ( "down" == direction ) then
         print( "Reached Bottom Limit" )
      elseif ( "left" == direction ) then
         print( "Reached Left Limit" )
      elseif ( "right" == direction ) then
         print( "Reached Right Limit" )
      end
   end

 



[TOPIC: post.html]
#2

iPlayalot

[GLOBAL: userInfoPane.html]
iPlayalot
  • Enthusiast

  • 65 posts
  • Corona SDK

I am loading images (network.download) and inserting to scrollview.

scroll jumps to top when inserting images



[TOPIC: post.html]
#3

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Thanks for the report @iPlayalot, we'll take a look...



[TOPIC: post.html]
#4

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 190 posts
  • Corona SDK

I cannot get anything but 0 from myScrollView:getContentPosition() - Docs say {x,y} should be returned. Build 2090



[TOPIC: post.html]
#5

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @jack95,

I just tested the following in #2093, and it works for me.

 

local sx,sy = scrollView:getContentPosition()
print(sx,sy)
 
Please check your code again and see if you can spot anything odd.
 
Brent


[TOPIC: post.html]
#6

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 190 posts
  • Corona SDK

If you do single return assignment:

 

local single = myScrollView:getContentPosition()

it is always 0 unless you are in the listener or a touchlistener (I think)

 

if you capture the return as per the documented example:

 

local x,y = myScrollView:getContentPosition()

 

you get the proper values. I guess I'm just not used to functions returning multiple values but there is a return value inconsistency based on where you capture the data.



[TOPIC: post.html]
#7

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @jack95,

Are you using a vertical-only scroll view (horizontal is locked)? If so, the 0 would make sense because the group can never go left or right, hence an x value of 0, which is the first parameter returned by the :getContentPosition() call.



[TOPIC: post.html]
#8

jurica007

[GLOBAL: userInfoPane.html]
jurica007
  • Observer

  • 2 posts
  • Corona SDK

Any news regarding this issue? Has it been fixed in the meenwhile? I've got the same problem (scrollview scrolls to top when inserting new items or even changing old ones).



[TOPIC: post.html]
#9

eja

[GLOBAL: userInfoPane.html]
eja
  • Contributor

  • 124 posts
  • Enterprise

I have also ran into this issue, loading more content to a scrollView will reset the scroll back to the top... Is there a plan for this fix?



[TOPIC: post.html]
#10

eja

[GLOBAL: userInfoPane.html]
eja
  • Contributor

  • 124 posts
  • Enterprise

I am having my users complain about this exact issue all the time... It's quite a bad user/dev experience (loading more content to a scrollView will reset the scroll back to the top), I tried using tableView's but the performance i get from it makes me fallback to use scrollView.

 

Corona, is there a fix coming for this? or is there a temporary decent fix? please!



[TOPIC: post.html]
#11

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @eja,

This fix is currently being tested/approved and will presumably go out soon. Worst case, we release an open-source fix or something along those lines for users (like yourself) who need a more urgent fix. Your patience is appreciated on this.

 

Brent



[TOPIC: post.html]
#12

eja

[GLOBAL: userInfoPane.html]
eja
  • Contributor

  • 124 posts
  • Enterprise

Hi @eja,

This fix is currently being tested/approved and will presumably go out soon. Worst case, we release an open-source fix or something along those lines for users (like yourself) who need a more urgent fix. Your patience is appreciated on this.

 

Brent

 

Brent thank you so much for getting back to me so promptly, this would mean so much! Anything would help.



[TOPIC: post.html]
#13

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

I tried using tableView's but the performance i get from it makes me fallback to use scrollView.

 

@eja

 

I am also trying to do something similar like yours, adding a lot of items into a scrollView/tableView while the user keeps scrolling down.

 

I am at the moment trying to choose using scrollView or tableView to do so.

 

When I see your earlier comment, it seems tableView performance is bad? How bad is it? So maybe I should just use scrollView directly? Any experience to share?

 

Thanks a lot.



[TOPIC: post.html]
#14

primoz.cerar

[GLOBAL: userInfoPane.html]
primoz.cerar
  • Contributor

  • 455 posts
  • Corona SDK

Table view performance depends on the complexity of the onRowRender listener as the rows get continually recreated while scrolling. If you load large images or insert a lot of objects in the row then performance while scrolling will be bad.



[TOPIC: post.html]
#15

joe528

[GLOBAL: userInfoPane.html]
joe528
  • Contributor

  • 800 posts
  • Corona SDK

@primoz.cerar

 

but with scrollView, I still need to do the same thing for each row rendering. And I also need to remove & re-create rows while scrolling. So why would tableView perform worse than scrollView? or should be the same?



[TOPIC: post.html]
#16

primoz.cerar

[GLOBAL: userInfoPane.html]
primoz.cerar
  • Contributor

  • 455 posts
  • Corona SDK

I don't know how you remove and recreate rows in your scroll view, but if you realy remove all the rows that go offscreen and then recreate them when they come in to view (or close) then it should be the same.

 

BTW this is off topic. You can PM me if you need more info.

 

For those that need a quick fix for the scrolling issue  I posted it in another thread here



[TOPIC: post.html]
#17

eja

[GLOBAL: userInfoPane.html]
eja
  • Contributor

  • 124 posts
  • Enterprise

@eja

 

I am also trying to do something similar like yours, adding a lot of items into a scrollView/tableView while the user keeps scrolling down.

 

I am at the moment trying to choose using scrollView or tableView to do so.

 

When I see your earlier comment, it seems tableView performance is bad? How bad is it? So maybe I should just use scrollView directly? Any experience to share?

 

Thanks a lot.

 

You can create your own "rows" by creating an obj as true object:

local rowReferences={}

local newRow={
	new=function(self,obj)
		local sMeta=setmetatable
		obj=obj or {}
		sMeta(obj,self)
		self.__index=self
		return obj
	end,
	render=function(self)
		self.displayGroup=display.newGroup()
		
		-- objects here

		print(self.isAwesome,self.coolBro)
		return self.displayGroup
	end
}

for i=1,50 do
	rowReferences[i]=newRow:new({isAwesome=true,coolBro=5})
	rowReferences[i]["view"]=rowReferences[i]:render()
	scrollView:insert(rowReferences[i]["view"])
end

-- to delete rows

rowReferences[2]["view"]:removeSelf()
rowReferences[2]["view"]=nil


[TOPIC: post.html]
#18

eja

[GLOBAL: userInfoPane.html]
eja
  • Contributor

  • 124 posts
  • Enterprise

btw, i think the reason performance is a lot better in scrollView vs tableView for me is because i have a lot of listeners in one row... When the tableView tries to add/remove so many objects while you scroll it goes completely nuts. 




[topic_controls]
 
[/topic_controls]