3

I'm fooling around with a function right now on this page.

If you click the "who" section the div rotates. I'd like it to zoom and consume the page.

Is this possible? How can this be done?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Greg
  • 567
  • 2
  • 14
  • 31

1 Answers1

4

After it rotates, set its width and height to be the width and height of the page.

$('#who').rotate({
    angle:-90,
    bind: [{
        click: function(){
            $(this).rotateAnimation(0);
        }
    }], // remove the trailing comma here
    callback: function (){
        var $window = $(window);
        $(this).height($window.height()).width($window.width());
    }
});

Edit re: OP's comments

$('#who').rotate({
    angle: -90,
    bind: [{
        click: function(){
            $(this).rotateAnimation(0);
        }
    }],
    callback: function (){
        $(this).width(800).height(600);
    }
});

See .height() and .width().


Edit #2

With your current CSS, you need to scale the img.

$('#who').rotate({
    angle: -90,
    bind: [{
        click: function(){
            $(this).rotateAnimation(0);
        }
    }],
    callback: function (){
        $('#who > img').animate({height: 600, width: 800});
    }
});

If you change, say, the image's height and width to be 100% then you only need to change the size of the div and the image should scale with it.

$('#who').animate({height: 600, width: 800});
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
  • Thanks. I tried that to no avail. I maybe doing it wrong. do i just plug the values in like so?.height($window.height(600)) .width($window.width(800)); for some reason my original coding is not working in firefox either! – Greg Mar 07 '11 at 17:05
  • @Greg: I've edited my answer after looking at how the rotate plugin works. Is that any better? – Matt Ball Mar 07 '11 at 17:19
  • Hey Matt, I've got it looking like this $('#who').rotate({ angle:-90, bind: [{ click: function(){ $(this).rotateAnimation(0); } }], // remove the trailing comma here callback: function (){ var $window = $(window); $(this).height($window.height(600)).width($window.width(800)); } }); does that look how you imagined? It still not doing the zoom. Thank you for your help! – Greg Mar 07 '11 at 17:24
  • @Greg: did you update it on your site? I don't see the latest version in your page. **Oh** and why in the world are you passing values into `$window.height()`? Are you trying to make the image itself 800 by 600? In that case, you don't need the `$window` part at all, just use this: `$(this).height(600).width(800);`. – Matt Ball Mar 07 '11 at 17:27
  • Im not sure why I did that. I was just trying becuase it wasnt working. The site is updated with your newest code. The idea is to have the div expand to 800 x 600. – Greg Mar 07 '11 at 17:37
  • Matt, thanks for your time man...but its still doing the same thing. – Greg Mar 07 '11 at 17:46
  • @Greg: no problem, I see what the problem is. In the callback, `this` does not point to the DOM element. Revising now. – Matt Ball Mar 07 '11 at 17:48
  • @Greg: nailed it. See my edit. FWIW, I don't think this is a well-written jQuery plugin. – Matt Ball Mar 07 '11 at 17:56
  • glad you are a genius! - Not to over step my bounds...have you any idea why this doesn't work in firefox? – Greg Mar 07 '11 at 17:59
  • @Greg: It doesn't work in Chrome, either. You have a syntax error in your code on the live site. `$(this).rotateAnimation(0, duration: 600);` is not valid JavaScript. – Matt Ball Mar 07 '11 at 18:14
  • @Greg: you need to pull the `duration: 600` out of the `rotateAnimation` function call, put it into the same object as the other parameters (like `angle`). – Matt Ball Mar 07 '11 at 18:17
  • @ Matt, Thanks again. I was fooling around in there with the options. I'm sitll pretty new to jquery. What's strange is....the plugin http://wilq32.adobeair.pl/jQueryRotate/Wilq32.jQueryRotate.html seems to work on the demo page....i wonder if i can shift things around to make it work... – Greg Mar 07 '11 at 18:29