Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That's absolutely possible, although there are a lot of ways you could structure it. Here is one of many possible solutions. I assume the presence of a Raphael paper object named <code>paper</code> throughout.</p> <p><strong>Location and Dimensions</strong></p> <pre><code> var cx = 180, cy = 125; /* These are the coordinates of the center point of your image(s) inside the paper */ var dx = 320, dy = 240; /* dx and dy describe the dimensions of the desired image interface. */ </code></pre> <p><strong>Image Information</strong></p> <p>I'd assume you'd want to load this information dynamically via ajax (depending on how your gallery is structured) or be able to re-use it. This example uses an array of objects describing the <code>url</code>, <code>width</code>, and <code>height</code> of each item in the list. For instance...</p> <pre><code> var imageList = [ { url: '/tests/images/sunset1.jpg', width: 1600, height: 900, }, { url: '/tests/images/moonrise1.jpg', width: 1024, height: 768, }, { url: '/tests/images/cityscape.jpg', width: 1920, height: 1080, }, { url: '/tests/images/forest03.jpg', width: 500, height: 325, }, ]; </code></pre> <p><strong>The Code</strong></p> <p>Last but not least, run this code when your DOM is ready (or after your images have loaded, or whatever other event should trigger it). This just creates a function to do the transition and then calls it to get the first image into place.</p> <pre><code> var imageIndex = 0; var rotationMultiplier = 1; var currentImage = null; function rotateTransitionNext() { rotationMultiplier *= -1; imageIndex++; if ( imageIndex &gt;= imageList.length ) imageIndex = 0; if ( currentImage ) { currentImage.animate( { transform: ["...r", 180 * rotationMultiplier, cx, cy], opacity: 0.0 }, 1000, '&lt;&gt;', function() { this.remove(); } ); } var newImage = paper.image( imageList[imageIndex].url, cx - dx / 2, cy - dy / 2, dx, dy ) .attr( { transform: [ "r", -180 * rotationMultiplier, cx, cy], opacity: 0.0 } ) .animate( { transform: [ "...r", 180 * rotationMultiplier, cx, cy ], opacity: 1.0 }, 1000, '&lt;&gt;', function() { currentImage = this; this.click( rotateTransitionNext ); } ); } rotateTransitionNext(); </code></pre> <p><strong>Loose Ends</strong> As a rough starting point, there are a few things that should be done to wrap this up:</p> <ol> <li><p>For goodness' sake, wrap this stuff up in its own namespace to avoid cluttering the global scope with detritus (my bad)</p></li> <li><p>Preserve aspect ratios of different images. Right now, all images are being forced to conform to the globally defined dimensions (dx and dy)</p></li> </ol> <p>Happy coding.</p> <p>UPDATE: <a href="http://voidblossom.com/tests/_imageRotateTransition.php" rel="nofollow">here</a> is a staged example of this code at work. Just click on the image to cause it to rotate to the next.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload