Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
38
rated 0 times [  45] [ 7]  / answers: 1 / hits: 16687  / 11 Years ago, wed, july 3, 2013, 12:00:00

Is there any good way for zoom in and zoom out functionality in a page using jQuery mobile. I goggled it and found



window.parent.document.body.style.zoom = 1.5;


Is there any better way to do zoom in and zoom out functionality in jQuery mobile?


More From » jquery

 Answers
16

Here is a sample workaround, DEMO http://jsfiddle.net/yeyene/aGuLE/



$(document).ready(function () {
$('#zoomIn').on('click', function () {
zoomIn(1.2);
});
$('#zoomOut').on('click', function () {
zoomOut();
});
});

function zoomIn(zoomLev) {
if (zoomLev > 1) {
if (typeof (document.body.style.zoom) != undefined) {
$(document.body).css('zoom', zoomLev);
}else {
// Mozilla doesn't support zoom, use -moz-transform to scale and compensate for lost width
$('#divWrap').css({
-moz-transform: 'scale( + zoomLev + )',
width: $(window).width() / zoomLev
});
}
}
}

function zoomOut() {
$(document.body).css({
zoom : '',
position : '',
left: ,
top: ,
-moz-transform : ,
width : ''
});
}

[#77239] Tuesday, July 2, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
briannar

Total Points: 354
Total Questions: 103
Total Answers: 101

Location: Japan
Member since Sat, Jun 6, 2020
4 Years ago
;