I am trying to implement components for Salesforce1 using touchstart, touchmove and touchend dom events on the dom elements inside my components. Normally the event that is passed to the callback function includes changedTouches attribute, which is also the case with Locker Service on. However, the objects inside this attribute are locked by the locker service which makes the touch functionality inaccessible. Does anyone know of an efficient way to access touch events?

Here is an example of the component that is using one of the event listeners:


<aura:component implements="force:appHostable"><!-- apphostable to be able to expose component as custom lightning tab -->
    <div aura:id="container">
        <div style="background:red; width:400px; height: 1000px;"></div>


afterRender: function( cmp, h ) {
    cmp.getElement().addEventListener('touchstart', function(e){
        var touchobj = e.changedTouches[0];
        console.log('touchstart', touchobj); // when locker service is on, touchobj is empty
    }, false);

Result on touch:

touchobj is empty


As Doug mentioned above, we have recently fixed this issue. The fixes were deployed yesterday(12/7/2016 after 6pm PST). I have tried your code and I can confirm that e.changedTouches[0] has the data. Here's a screenshotenter image description here

  • Hi Ravi, thanks for your post but I still have the same problem. I have updated the code that I am using and included the result in my original post.
    – Artur
    Dec 8 '16 at 22:55
  • @Artur Were you using Google Chrome's(GC) Toggle device toolbar to simulate a touch device? I saw the same behavior when I used GC to simulate the touch events. When I used the iPad simulator and touched the dom node, the events has the correct properties. Can you please try your scenario on the iPad simulator? Dec 9 '16 at 0:54
  • I indeed am using GC as my go-to tool. Unfortunately I am not a mac user to be able to use ipad simulator. Is there something about Chrome Simulator that doesn't work, or should we expect inconsistent behaviour in different mobile browsers as well?
    – Artur
    Dec 9 '16 at 1:28
  • 1
    @Artur I have filed a bug for your issue and will be looking into it. W-3559671 is the bug number. Appreciate your effort in providing good repro steps and reporting this issue. We, on the Locker Service team, monitor this forum actively. Dec 9 '16 at 18:35
  • 1
    @Artur The fix for this is making its way now as part of the Winter 17 release. Some of the sandbox instances are already on Winter 17, if that is where your org is. Jan 10 '17 at 20:30

We've recently fixed at least one touch event specific issue in Winter'17 .16 patch (deploying this week I believe) but I am not sure if that is the issue you are seeing. Do you have a support case open on this already?

  • Unfortunately I don't have access to the premier support to open a developer specific case. Is there a way to open a case without premier support?
    – Artur
    Dec 8 '16 at 14:29
  • 3
    @Artur - Nope, SF relies on paid support to identify bugs. Developers are discouraged from reporting any bugs at all (tongue-in-cheek, but it feels that way). Honestly though, the folks monitor SFSE if you use the appropriate tags which you did and it seems like it is getting noticed.
    – Eric
    Dec 8 '16 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.