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

CSS :active pseudo class no longer triggers in 10.1+

by Retired on ‎06-14-2013 02:05 PM (2,353 Views)

Since BlackBerry 10 OS version 10.1, DOM elements no longer trigger their CSS :active pseudo class when touched, unless a 'touchend' event is attached. These no longer trigger when using 'click' events. This was done for performance reasons.

 

For example, If you are using CSS :acive pseudo class to highlight menu items for example, they will need to change the listeners from:

 

//from
someDiv.addEventListener(‘click’,function,false);
//to
someDiv.addEventListener(‘touchend’,function,false);

To keep the code cross-platform (touchend only works on touchscreen devices, not desktop), you can create a little helper function as such:

 

var clickOrTouch = 'ontouchstart' in window ? ‘touchend’ : ‘click’;

 And then use clickOrTouch instead:

 

someDiv.addEventListener(clickOrTouch,function,false);

This will query the browser to see if touch is supported and use touched instead of click.

Contributors
Comments
by New Developer
‎12-30-2016 02:27 PM - edited ‎12-30-2016 02:28 PM

anzor_b wrote:
For example, If you are using CSS :acive pseudo class to highlight menu items for example, they will need to change the listeners

Given how highlighting a menu item is an almost effortless achievement when done in CSS alone, the gesture of basing your sole suggesting for a fix on the assumption that developers are implementing JS code for such a CSS-specific purpose anyway is frankly excessively non-chalant and offensive.

 

Before coming across this obscure post, I have spent hours trying to solve the problem that the :active pseudoclass doesn't respond. Now I know that it has been deliberately removed, a decision that seems unfathomable to me given its extensive use on the Web and the inevitable ensuing expectation of its universal existence among new BB10 developers, yet I still do not know how to bypass this decision without pouring utterly redundant JS all over my stylesheet.

by New Developer
on ‎12-30-2016 02:59 PM

Time further wasted, and here I present other frustrated developers with something approaching a real fix, albeit with drawbacks: http://stackoverflow.com/a/33681490/1662230

Users Online
Currently online: 21 members 1,553 guests
Please welcome our newest community members: