0

I would like to do something similar to the effect in the link below.

http://wallbase.cc/wallpaper/549871

The image is initially rendered depending on the users screen resolution, and if the image is larger than the screen resolution of the user,on click the image in resizes in steps.

Can somebody guide me how to go about it.

I am not that good in jQuery,So would appreciate a "For Dummies" approach.

Thanks

2 Answers 2

3

It's pretty simple. All that's happening is that a click event on the image is changing the image's width and height. Something like this:

var img = $('img');
var zoomWidthIncrement = img.width() * 1/3;
var zoomHeightIncrement = img.height() * 1/3;

img.click(function(){
    img.css({width: img.width() + zoomWidthIncrement, height: img.height() + zoomHeightIncrement});
});

You could also animate this zoom simply by using animate() to change the css values.

Sign up to request clarification or add additional context in comments.

2 Comments

You mean my superior math skills? ;) Nah, just wondered why didn't you do "/3" right away. Still upvoted you.
For educational clarity. The OP is a noob, and I thought it would be clearer this way. Probably makes no difference though.
0

I recently used this in a project aswell. you could try this: You need 2 versions of the pictures for this method, a normal one and a zoomed one.

$('#myDiv').click(function () {
    if ($('#myDiv').length != 0) { return; }
    $('body').prepend('<div id="myDiv" class="mapTileOverlay"></div>');
    $('#myDiv').html('<div class="topOverlay"></div><div class=" overlayLarge"><div class="jqContentContainer"><div class="closeArea"><img src="<%=Utility.RawApplicationPath%>/static/images/game/office/closeButton.png"></div><img class="illustration" src="myImgBigVersion"  alt="Text illustration"></div></div><div class="bottomOverlay"></div>'); //<form class="formPMPStart" method="post" action="/game"><input type="submit" id="btnStart" class="gameContinue" value="Continue" /></form>
    $('#jqmdeskComputer').jqm({ modal: false, onShow: myOpen, onHide: myClose }).jqmAddClose($('div.closeArea')).jqmShow();
});

Probably not exactly what you wanted but I hope this code can help you get what you had in mind :)

3 Comments

@maxedison solution is probably better and easier. But if you zoom in on a small picture it can get blurry.
My solution assumes that the image you're zooming in on is the full-resolution one, just as it is in the example offered by the OP.
I know, thats why I gave you a +1 mate ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.