-
Notifications
You must be signed in to change notification settings - Fork 85
A Polyfill for @media (hover)
#159
Comments
I'm typing this comment on a touchscreen laptop. |
Really not gonna do the job, is it... My PC would currently match the 'hover' rule in this script, even though there isn't a mouse or any other hover-capable device connected. There are probably loads of other false-positives / false negatives. The main use cases for the original spec were to enable functionality which requires hover capability for those with such a capability. Subsequent discussions have put emphasis on this MQ depending on manufacturers' insight into how they expect their devices to be used… the complexity of this may explain why we haven't seen much uptake. That said, in a few tests I had reasonable success detecting a "hover user" by looking for 2 consecutive Obvious downside being that you never know if they're not a hover user: just that they haven't used hover yet. Not sure how you'd convey an |
Yeah, in general - as I've written before - the solution isn't pivoting your hover use based on the device's capability for hover, it's to never design an interface around hovering. Even on devices that do support "proper hovering", I, as a user, don't want to deal with them. |
Hover is incidental.A hover represents a tentative, potential interaction, and not an actual, intentional user action. A hover is a slight glimmer above the surface of interaction, across paradigms - it's moving your cursor to show that you're looking at the link, not touching it. Anything that uses hover should only be adding a thin veneer of flair. This veneer should be designed with the state of mind that the hover might not occur, out of device support, laziness, privacy, coincidence, or otherwise. Designing around the presence of potential hover is bad design. Designing based on assumptions around the only two pointer interaction paradigms you currently know of is incredibly shortsighted, especially at this point in time where there is so much consumer innovation in the space. It's short-sighted designs like this that necessitated the awful "drag a virtual mouse around" hack on Windows tablets circa Windows 7 - because lame UX designers couldn't imagine a world without mice. Designing based on thinking that "some devices support hover and some don't" is to have the same kind of short-sightedness, not being able to imagine a world without cursors or fingers. |
I agree. My main use-case is (when possible) making buttons a darker color on |
@cvrebert Ech, I see. It seems like this would be better handled by a polyfill that removes that behavior from UAs like FastClick, though. |
And/or a combination of meta-tags that signals not to do sticky hover (the way setting a viewport or disabling zoom or whatever disables tap-to-zoom and removes the need to polyfill with FastClick). |
Yeah, Chrome has an open bug for that. But it hasn't been implemented yet, I haven't seem any movement from the other browser vendors on it, and it will never solve Android pre-v5, which an annoying amount of people care about. |
You think it would, or you've actually tried it (test page here) and it does? What kind of device and browser? I'd love to hear details.
Well, that's the beauty of open source, isn't it? The community tries things out in a kajillion environments, finds where they break, and then they get fixed. |
Given the use case, I think this is quite tidy. Potentially flaky detect, sure, but hidden away so CSS authors can just use an MQ everywhere they need it and it's not the end of the world when edge cases slip through the net. And no need to deal with the notoriously inconsistent event firing sequences of input devices. |
Fair call, I was assuming that most desktop browsers don't support it natively yet and wouldnt be blacklisted by your "touch" checks, so would report hover capable — but I'll test it fo' real tomorrow. |
On the flip side, It thinks my touch-enabled Chromebook does not support hovering:
|
@stuartpb As mentioned on https://github.com/cvrebert/mq4-hover-hover-shim#browser-side-feature-detector
It's the best we can do in browsers that lack the Working Draft's "primary pointer" concept. |
From the CSS Media Queries Level 4 draft.
I think a server-side CSS postprocessor that converts
into
(with the name of the
.no-touch
class being customizable) would be a good option.The text was updated successfully, but these errors were encountered: