Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
razorek
Posts: 65
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE
Accepted Solution

Are the touch events in new Ripple broken ?

Hi,

 

I have a PlayBook application that uses touch events for moving stuff around. I've been testing it in the standalone version of Ripple and on the physical device.

Now I'm thinking about porting the app to BB10, so I downloaded the Chrome verion of Ripple and I found that in the new Ripple I can't move any object!

 

I've identified the problem but I don't know how to deal with it. Here is a small HTML file that shows the problem:

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
    <div id="container" style="background-color: Green; width: 500px; height: 500px">
        <div id="child" style="position: absolute; left: 100px; top: 100px; background-color: Red; width:50px; height: 50px">child</div>
    </div>
    <script type="text/javascript">
        function onTouchStart(e) {
            alert("touch start");
        }

        var container = document.getElementById("container");
        container.ontouchstart = onTouchStart;
    </script>
</body>
</html>

So basically there is a container div that listenes to touchstart event and if it happens it shows an alert. In the old Ripple (and on the PlayBook device) if you press on the "child" div the alert is also shown (the event is pushed down and intercepted by the container). In the new Ripple it doesn't happen.

 

Any suggestions? Can I force Ripple to act as the Playbook does? Or maybe I should use some other technique for catching touch events?

Please use plain text.
BlackBerry Development Advisor
anzor_b
Posts: 164
Registered: ‎09-24-2012
My Device: White BlackBerry 10

Re: Are the touch events in new Ripple broken ?

Hi razorek,

 

I am not sure about the reason (its WebKit behaviour), but using AddEventListener will allow for event propagation when using touchstart. Take a look:

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
    <div id="container" style="background-color: Green; width: 500px; height: 500px">
    	
    	
        <div id="child" style="position: absolute; left: 100px; top: 100px; background-color: Red; width:50px; height: 50px">child</div>
   
   
    </div>
    <script type="text/javascript">
        function handleTouchStart(e) {
            alert("touch start");
        }

        var container = document.getElementById("container");
        
        container.addEventListener('touchstart',handleTouchStart);
    </script>
</body>
</html>

 Also, when using Ripple for Chrome, please make sure that  "Emulate touch events" is not checked, as Ripple has it's own touch emulation system and it may clash with it.

 

F12 (Open Developer Tools) > Click the gears icon in the bottom right corner > Overrides tab > Emulate Touch Events. I will also post this workaround in the github page for this issue https://github.com/blackberry/Ripple-UI/issues/344

 

Please use plain text.
Developer
razorek
Posts: 65
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE

Re: Are the touch events in new Ripple broken ?

Thank you anzor_b, works like a charm :smileyhappy:!

Please use plain text.