0

I have use elevateZoom jquery plugin. I want to disable elevateZoom in mobile(less than 600px width device).

So, How can I add(if condition) zoomEnabled: false, instead of zoomEnabled: true, in below jquery. when Open in mobile.

<script>
$("#zoom_01").elevateZoom({
    gallery:'gallery_01',
    zoomEnabled: true,
    cursor: 'pointer',
    galleryActiveClass: 'active'
</script>
HDP
  • 3,003
  • 2
  • 28
  • 50

2 Answers2

1

You can use the .width method in jquery to determine the width of the window and just change the object properties accordingly.

You can use it like this:

<script>
if ($( window ).width() < 600) {
  $("#zoom_01").elevateZoom({
  gallery:'gallery_01',
  zoomEnabled: false,
  cursor: 'pointer',
  galleryActiveClass: 'active'
} else {
  $("#zoom_01").elevateZoom({
    gallery:'gallery_01',
    zoomEnabled: true,
    cursor: 'pointer',
    galleryActiveClass: 'active'
}
</script>
Yousef_Shamshoum
  • 737
  • 3
  • 12
  • I have try. but, I have not success. How can I add this in our above script. any idea. Thanks. – HDP Sep 22 '14 at 09:44
0

A more readable approach (at least for me):

<script>
    $("#zoom_01").elevateZoom({
        gallery:'gallery_01',
        zoomEnabled: ( $(window).width() >= 600 ),
        cursor: 'pointer',
        galleryActiveClass: 'active'
    });
</script>

but to be fair: read a javascript tutorial or 2 and you could've figured this out yourself.

DoXicK
  • 4,492
  • 22
  • 21