user2045025
user2045025

Reputation:

media queries for javascript

in javascript i have given the cube size.... how to reduce the cube size for iphone screens is it possible to reduce the cube size using media queries in javascript.... how to make the cube size to 50 for iphone screens

http://jsfiddle.net/XNaYj/

Gallery = {
        _config: {
            speed: 500,
            size: 100,
            lightbox: !0,
            closeOnEsc: !0,
            animation: "default",
            slideshow: !1,
            slideshow_speed: 3E3,
            cube_speed: 1E3
        },

Upvotes: 1

Views: 220

Answers (2)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324630

The JavaScript equivalent to the following CSS:

@media all and (max-width:360px) {
    ...
}

is:

if( (window.innerWidth || document.documentElement.clientWidth) <= 360) {
    ...
}

Upvotes: 2

adeneo
adeneo

Reputation: 318182

It's generally not a great idea to do browser or device sniffing, and feature detection would probably be better, but to answer the question, something like:

Gallery = {
    _config: {
        speed: 500,
        size: 100,
        lightbox: !0,
        closeOnEsc: !0,
        animation: "default",
        slideshow: !1,
        slideshow_speed: 3E3,
        cube_speed: 1E3
   }
}

if((navigator.userAgent.match(/iPhone/i)) Gallery._config.size = 50;

Upvotes: 0

Related Questions