File a bug report with apple. http://bugreporter.apple.com/

On Thu, Jan 8, 2009 at 8:42 AM, Rick Schramm <[email protected]> wrote:
>
>
>
> On Jan 8, 2:40 am, Matteo <[email protected]> wrote:
>> I noticed that in some examples at developers.apple.com Apple is
>> adding event listeners on the fly and removing them as soon as they
>> are not required. In the drag-n-drop example they add the touchmove
>> and touchend events at the end of the touchstart:
>>
>> this.element.addEventListener('touchmove', function(e) { return
>> self.onTouchMove(e) }, false);
>> this.element.addEventListener('touchend', function(e) { return
>> self.onTouchEnd(e) }, false);
>>
>> and they try to remove them on touchend:
>>
>> this.element.removeEventListener('touchmove',function(e){return
>> self.onTouchMove(e)},false);
>> this.element.removeEventListener('touchend',function(e){return
>> self.onTouchEnd(e)},false);
>
> LOL.  That dog don't hunt.
>
>>
>> As far as I can tell there's no way to remove an anonymous function
>> with removeEventListener. Initially I thought it was a webkit feature
>> but it turned out that the events are indeed never removed, so at
>> every touchstart two new events are appended (a big memory problem).
>
> Yep.  Beware of examples from strangers, regardless of the domain.
>
>>
>> a very quick and dummy solution could be to create the event with
>> something like:
>>
>> this.element.addEventListener('touchmove', obj = function(e) { return
>> self.onTouchMove(e) }, false);
>>
>> and remove it with:
>>
>> this.element.removeEventListener('touchmove', obj, false);
>
> Something like that.
>
>>
>> I'm not trying to discredit the examples at developers.apple.com, they
>
> You succeeded in discrediting a bad example.  No need to apologize for
> that.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to