-1

i'm writing a website on which everything should be able to be zoomed except of one object. Is it possible to prevent only this object from being zoomed (typical pinch gesture on ipad, iphone)? (I know you shouldn't do this because zoom should entlarge everything on the page... but i don't know a way around.)

It has only to run on mobile safari.

Thanks for your help.

palme
  • 2,499
  • 2
  • 21
  • 38
  • 1
    I don't think this is possible... – elclanrs Feb 09 '12 at 21:51
  • why did i get a minus on my question? – palme Feb 09 '12 at 23:04
  • 1
    The down vote is probably because your question doesn't show what research you've already done / solutions you've tried. I personally don't have a problem with the question (it's hard to know where to start) but elaboration will usually help get upvotes for your question. – Ben D Feb 10 '12 at 03:00
  • thanks for your answer. i will keep that in my for future posts. (i actually did a lot research on this subject that's why i for example could write that this way is definitely not the way you do this.) – palme Feb 10 '12 at 23:40

1 Answers1

2

In order to do this, you need to be able to detect the zoom, which is not possible... at least, not directly. This post introduces a rather novel way of detecting the zoom level by using javascript to compare the width ratio of two divs on the page: one with a pixel-defined width and the other with a percentage-defined width. When the user pinches/zooms, the pixel width will not change, but the percent width will, so if you use javascript to detect the offset width of these two objects and get the ratio you can get the zoom. Then, if the ratio is, say, 150%, you can change change the width and height of you "fixed" object (using javascript) and multiplying each by .66666.

The major challenge you face here is that you cannot detect the moment of a zoom, so you'd have to use a setInterval() call to constantly be checking the ratio of the two test divs.

Community
  • 1
  • 1
Ben D
  • 14,321
  • 3
  • 45
  • 59
  • thanks for your answer. i knew this would be tricky. i get your idea but i see this is not a very elegant way. i will try to do it but i don't think the result will be as good as expected. – palme Feb 09 '12 at 23:05