IjzerenHein / famous-flex

Animatable layouts, FlexScrollView & widgets for famo.us.
MIT License
279 stars 44 forks source link

Clear Viewsequence Error on FlexScrollView. #66

Closed trobbertze closed 9 years ago

trobbertze commented 9 years ago

Hi

This is a little bit complex to reproduce. But here goes.

If you have a long sequence of lets say 30 items. Scroll down to the very bottom.

Now execute an event that will clear the sequence and replace it with a much shorter sequence, lets say 10 items.

The 10 new items are not rendered within view and it is impossible to scroll to those items.

IjzerenHein commented 9 years ago

Hi Theo. What layout are you using? And are you using alignment 1? Cheers

trobbertze commented 9 years ago

Im using the standard FlexScrollview.

The only options that I set is: direction: 1, scrollDrag: 10, flow: true

On Mon Feb 09 2015 at 10:07:08 PM Hein Rutjes notifications@github.com wrote:

Hi Theo. What layout are you using? And are you using alignment 1? Cheers

— Reply to this email directly or view it on GitHub https://github.com/IjzerenHein/famous-flex/issues/66#issuecomment-73580036 .

IjzerenHein commented 9 years ago

What are the functions you are calling to clear the sequence?

trobbertze commented 9 years ago

At first I used just a normal array as a sequence and then spliced it.

I then tried using a proper ViewSequence and did

sequence.splice(0, sequence._.array.length)

But that had the same effect.

Seems as if the sequence cannot find the first node once it is cleared like that.

On Mon Feb 09 2015 at 10:14:13 PM Hein Rutjes notifications@github.com wrote:

What are the functions you are calling to clear the sequence?

— Reply to this email directly or view it on GitHub https://github.com/IjzerenHein/famous-flex/issues/66#issuecomment-73581281 .

IjzerenHein commented 9 years ago

The ViewSequence is not the best invention of famo.us imho... When you clear the view-sequence in that way, the ScrollView will still hold a reference to one of the removed view-sequence nodes. There is no proper way for the scrollview to detect that the view-sequence was cleared out. The FlexScrollView contains a function called 'removeAll' which should always properly clear the content, please use that function.

trobbertze commented 9 years ago

Thanks Hein

Worked like a charm!

Only thing to note is that you have to set the datasource again afterwards.

Cheers

Theo

On Mon Feb 09 2015 at 10:30:42 PM Hein Rutjes notifications@github.com wrote:

The ViewSequence is not the best invention of famo.us imho... When you clear the view-sequence in that way, the ScrollView will still hold a reference to one of the removed view-sequence nodes. There is no proper way for the scrollview to detect that the view-sequence was cleared out. The FlexScrollView contains a function called 'removeAll' which should always properly clear the content, please use that function.

— Reply to this email directly or view it on GitHub https://github.com/IjzerenHein/famous-flex/issues/66#issuecomment-73583997 .

IjzerenHein commented 9 years ago

Awesome :+1:

Please close the issue if you feel it was answered satisfactory.