08-23-2021 19:57
08-23-2021 19:57
I was wondering why I was getting an ever-increasing number of touch listener events. Whenever a tile got reused, the previous listener remained so two events got triggered for one touch. When the list is scrolled up and down many times, any one tile gets reused multiple times so you can get heaps of events triggered by a single touch.
I think the problem is that the documentation suggests using addEventListener. This means that an ever-lengthening chain of listeners gets created, probably preventing virtual tiles from being garbage-collected. Eventually the app would run out of memory and crash.
The solution seems to be to use onclick rather than addEventListener(). onclick replaces any previous listener, instead of adding another one to the chain.
If this is right, it would be good if the documentation could be updated.
08-26-2021 03:30
08-26-2021 03:30
oh great catch! thanks