ryanve / response.js

Responsive design toolkit
http://responsejs.com
Other
801 stars 123 forks source link

New methods for device- and vertical-based tests #2

Closed ryanve closed 12 years ago

ryanve commented 12 years ago

In the upcoming version 0.2.9 I'm considering introducing some new methods. Currently we have Response.band(min, max) for testing whether the width of the viewport is in a min/max breakpoint range. I want to name the methods in a way that makes them easy to understand, keeps them in line with existing methods, and keeps them as concise as possible.

Proposed new methods

They'd add very little overhead so, and seem like worthwhile additions, right? As for the names, I think the use of .height should be avoided as to avoid confusing it with the native property or with jQuery's .height() method. .vertical and .device both seem pretty understandable (right?) but it also starts to get a bit long. It'd save some bytes if we just use .v as shown below.

Naming scheme 2

So what's better? .vertical (longer, more semantic) OR .v (shorter, less semantic) OR something different entirely?

ryanve commented 12 years ago

Ok so after thinking about this for a bit I decided to use a new method name wave for the vertical tests rather than having sub objects. It's way easier to type and it's easy to understand if you imagine a big wave at the beach (we gotta have some fun too ;). So here's what we have:

Response.band(min, max) tests viewport width ranges. @since 0.1.1 Response.wave(min, max) tests viewport height ranges. @since 0.2.9 Response.device.band(min, max) tests device-width ranges. @since 0.2.9 Response.device.wave(min, max) tests device-height ranges. @since 0.2.9 Response.dpr(min, max) tests device-pixel-ratio ranges. @since 0.2.0