-
Notifications
You must be signed in to change notification settings - Fork 12
Treatment of hover state on devices without hover capability #65
Comments
I use this approach too. Also for things like navigation I use something like: .ig-hoverable .navbar a:hover,
.ig-touch .navbar a.active { color: blue } And some things like Chrome Pixel could get either/both classes. I think it would be good to agree on something like this and get the product dev to add the classes to the body. It's essentially extending the idea of having agreed feature classes (alla Modernizr) on the root node. |
Ideally rather than specifying classes you'd use a variable with documented configurable selectors, so the product could combine several into one if they didn't need the granularity. @richard-still-ft could you review this, as I think you wrote the line I quoted in the issue description. |
Nudging @richard-still-ft |
Actually I think it was @dansearle-ft who wrote the quoted line. Personally I would prefer not to introduce a dependency on script to make components behave. For responsive articles the mantra is to design touch friendly components without designing in pointer specific functionality, hover states should only be used where they have no impact. It remains to be seen though how practical that is. |
Agreed that this should be approach, on the basis that from the perspective of a product developer:
I'll implement a module to do this. |
Is it worth turning this on its head
Then if we go forward with @kavanagh's suggestion #86 and #88 (comment) this could be put in a Modernizr plugin Modernizr.add('hover', function(){
if (initial test for touch) {
on('mousemove', function () {
html.className = html.className.replace('no-hover', 'hover');
Modernizr.hover = true;
})
return false;
} else {
return true;
}
}); |
The problem with modernizr is that it doesn't have a commonJS interface, so we can't build it in as a dependency of components. Feel free to open a new issue to discuss how we might use Modernizr, because I don't see a robust way of including it in Origami right now. |
I'm not sure that Modernizr test callbacks are executed in a predictable order. i.e the touch test might not have been evaluated before this test. |
I like the idea of :hover working by default, but doing that would result in more verbose CSS, as you'd have to override the hover state when the
Also, Modernizr could do the initial test, but could it do the ongoing mousemove/touch event handling? |
Also a window can be moved between a non-touch and touch screen. I think I like the idea. I'm not sure yet. |
Doesn't really matter if the screen supports touch or not - we're not proposing to turn touch off. If you loaded the page on a device that didn't have a mouse and then plugged one in, it would immediately acquire hover effects as soon as you moved your mouse over the page. |
@kavanagh Any test callbacks you add using Modernizr.add must surely be run after synchronous internal modernizr tests, and https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js is synchronous @dansearle-ft Good point. It could still support the normal way around, with the need for the product developer to hard code |
@triblondon I meant that the event listener is added only if touch is supported. At the time the Modernizr test is evaluated in the code above touch might not be supported but might be in the future of the page's lifespan, hence the hover class would never get added. I think I dont like the idea. |
I've published my lib here: Still concerned that there's no safe way to rely on Modernizr in a component, so if you want to pursue that, could you make the case in a new issue? |
Currently the standard says:
At Labs our preferred option is to prevent hovering on devices that lack hover capability, by adding a
.hoverable
selector prefix to all hover pseudoclass selectors:and then only adding it to the
<body>
element if the input device has hover capability. This also means that hovering can trivially be disabled when it would get in the way, eg during scrolling or animation. This would however require product developers to add the hoverable class to their body element if they wanted any of the origami components on the page to support hover. Thoughts?The text was updated successfully, but these errors were encountered: