Skip to content

Commit

Permalink
Refactored image sequences utilizing the data normalization to conver…
Browse files Browse the repository at this point in the history
…t sequence string into array. This allows for realtime image sequence string change. #190
  • Loading branch information
pisi committed May 17, 2013
1 parent ec5a01f commit 91e68a1
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 3 deletions.
1 change: 1 addition & 0 deletions example/index.html
Expand Up @@ -24,6 +24,7 @@ <h1>jQuery Reel Examples</h1>
<li><a href="panorama-sprite/">panorama-sprite</a></li>
<li><a href="panorama-sprite-local-assets/">panorama-sprite-local-assets</a></li>
<li><a href="realtime-image-switching/">realtime-image-switching</a></li>
<li><a href="realtime-sequence-switching/">realtime-sequence-switching</a></li>
<li><a href="realtime-direct-sequence-switching/">realtime-direct-sequence-switching</a></li>
</ul>

Expand Down
32 changes: 32 additions & 0 deletions example/realtime-sequence-switching/README.markdown
@@ -0,0 +1,32 @@
jQuery Reel Realtime Sequence Switching Example
===============================================

Utilizing the `.reel()` method to change running Reel's data allows you to
seamlessly switch image seuquences without affecting the state of animation
or rotational position of a running Reel. Feature ideal for various product
configurator setups. This example switches is made of 6 frames long sequence
(2 sets in fact) and since this non-looping image depicts mere 80°, custom
revolution is used to improve drag responsiveness.


Options Employed In This Example
--------------------------------

- [frames](http://jquery.vostrel.cz/reel#frames)
- [images](http://jquery.vostrel.cz/reel#image)
- [loops](http://jquery.vostrel.cz/reel#loops)
- [revolution](http://jquery.vostrel.cz/reel#revolution)
- [speed](http://jquery.vostrel.cz/reel#speed)

See the complete source of [index.html](index.html) for full
implementation.


---
&copy; 2009-2013 Petr Vostřel, part of [jQuery Reel][reel] project, under [GPL][GPL] and [MIT][MIT] licences



[reel]:http://jquery.vostrel.cz/reel
[GPL]:http://opensource.org/licenses/GPL-2.0
[MIT]:http://opensource.org/licenses/MIT
Binary file added example/realtime-sequence-switching/blue/1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/blue/2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/blue/3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/blue/4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/blue/5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/blue/6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/green/1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/green/3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/green/4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/green/5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/realtime-sequence-switching/green/6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions example/realtime-sequence-switching/index.html
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html data-type="example" data-id="realtime-sequence-switching">
<head>
<title>jQuery Reel Realtime Sequence Switching Example</title>
<meta charset='utf-8' content='text/html' http-equiv='Content-type' />

<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.vostrel.cz/jquery.reel-edge.js' type='text/javascript'></script>

<!-- Common examples style (gray background, thin fonts etc.) -->
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Realtime Sequence Switching</h1>

<img id="image" src='blue/1.png' width="160" height="120" />
<div>
<button id="green">Green</button>
<button id="blue">Blue</button>
</div>
<script>
$(function(){ // when DOM ready

$('#image').reel({
indicator: 5, // For no indicator just remove this line
images: 'blue/#.png',
frames: 6,
loops: false,
speed: 0.5,
revolution: 100
});

$('#blue').click(function(){
$('#image').reel('images', 'blue/#.png');
});

$('#green').click(function(){
$('#image').reel('images', 'green/#.png');
});

});
</script>

<p class="credits graphic"><a href="http://bknilssen.no">Bjørn Kåre Nilssen</a></p>

<div class="ballast">
<p>Lots of dummy text ballast to stretch the page a little and allow testing how each Reel mode behaves in relation to page scrolling.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed rutrum semper imperdiet. Integer non auctor orci. Nullam dictum pretium metus, interdum congue sapien lobortis in. Donec sed massa a tellus dapibus auctor et in mauris. Curabitur adipiscing fermentum felis vel molestie. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut semper sem ut nulla fringilla luctus. Curabitur dignissim quam ac libero consequat tincidunt. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Nunc sed lectus eget magna suscipit tempor eget id nibh.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eget lorem est, quis rhoncus augue. Proin mollis elit in lorem dignissim in pulvinar quam egestas. Praesent auctor tempus vestibulum. Praesent purus nisl, porta vel rhoncus mollis, suscipit a sapien. Suspendisse potenti. Nunc leo elit, auctor sed malesuada vel, accumsan in arcu. Quisque a turpis arcu. Fusce a dolor ut risus condimentum feugiat. Aliquam eget turpis ipsum. Fusce est metus, vulputate a mollis non, pretium sit amet mauris. Ut aliquam placerat risus ac volutpat. Phasellus dictum turpis ac nisi egestas faucibus. Nulla pretium molestie venenatis. Integer tincidunt imperdiet turpis, at pretium neque consequat at. Aenean id augue in odio elementum malesuada in in purus.</p>
<p>Donec in tincidunt tortor. Donec laoreet adipiscing orci ut gravida. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla eget luctus neque. Aenean metus massa, sodales non pulvinar vitae, dignissim ut ipsum. Pellentesque eget arcu ultrices nisl blandit egestas id quis augue. Integer volutpat, ligula sit amet convallis consequat, nulla nisl suscipit felis, in aliquam tellus sapien ut lorem. Fusce eget lorem diam. Sed sit amet consectetur mi. Nullam nibh dui, auctor at ullamcorper a, vulputate quis mauris. Morbi feugiat lorem et libero dapibus bibendum vel non augue. Fusce luctus enim ac velit semper pharetra. Curabitur turpis nibh, tempor eget rhoncus ut, vulputate et metus. Sed rutrum eros id nisl pharetra mollis. In hac habitasse platea dictumst.</p>
<p>Duis fringilla urna vel leo molestie eu pellentesque turpis consequat. Aliquam ante magna, pretium a facilisis vitae, viverra eu dui. Curabitur augue ligula, scelerisque et dapibus non, pharetra eu arcu. Aliquam lobortis augue et elit accumsan porttitor. Donec gravida dignissim lorem, porta vulputate augue tincidunt at. Vivamus tincidunt, tellus et volutpat fermentum, enim metus bibendum ante, euismod feugiat velit nisi nec tellus. Pellentesque egestas, sapien convallis tempor vestibulum, mauris nisl lobortis metus, sagittis vulputate lacus ante ut dolor. In hac habitasse platea dictumst. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tristique velit ac tellus ullamcorper quis pellentesque ipsum cursus. Praesent luctus fringilla velit, eu placerat tellus luctus ac. Nulla nec massa quam.</p>
<p>Praesent rutrum dui congue massa dictum tincidunt. Pellentesque ac volutpat augue. Fusce vel dui ac enim viverra sodales. Etiam massa sapien, fermentum et ultricies at, placerat vitae eros. Sed convallis vehicula commodo. Mauris sit amet augue id turpis dapibus rhoncus et vel turpis. Nullam vitae massa sed nunc sagittis varius ac id sapien. Morbi ligula tellus, consequat ut pellentesque id, condimentum nec est. Donec id elit mollis diam dignissim iaculis sed nec lorem. Vivamus sed tellus venenatis sem viverra aliquet gravida nec neque. Donec facilisis odio ac nisl iaculis gravida. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer in augue nec leo interdum adipiscing ut a quam. Aenean sit amet mauris vitae lacus interdum aliquam vel a erat.</p>
</div>
</body>
</html>

10 changes: 7 additions & 3 deletions jquery.reel.js
Expand Up @@ -752,15 +752,13 @@ jQuery.reel || (function($, window, document, undefined){
id= set(_id_, t.attr(_id_) || t.attr(_id_, klass+'-'+(+new Date())).attr(_id_)),
styles= t.attr(_style_),
data= $.extend({}, t.data()),
images= opt.images,
images= set(_images_, opt.images || []),
stitched= opt.stitched,
loops= opt.loops,
orbital= opt.orbital,
revolution= opt.revolution,
rows= opt.rows,
footage= opt.footage,
sequence= reel.re.sequence.exec(images),
images= set(_images_, sequence ? reel.sequence(sequence, opt, get) : images || []),
size= { x: t.width(), y: t.height() },
frames= set(_frames_, orbital && footage || rows <= 1 && images.length || opt.frames),
multirow= rows > 1 || orbital,
Expand Down Expand Up @@ -2091,6 +2089,12 @@ jQuery.reel || (function($, window, document, undefined){
frames= data[_frames_] * (opt.orbital ? 2 : opt.rows || 1),
result= round(opt.loops ? frame % frames || frames : min_max(1, frames, frame))
return result < 0 ? result + frames : result
},
images: function(images, data){
var
sequence= reel.re.sequence.exec(images),
result= !sequence ? images : reel.sequence(sequence, data[_options_])
return result;
}
},

Expand Down
23 changes: 23 additions & 0 deletions test/unit/computation.js
Expand Up @@ -196,6 +196,29 @@
});
});

asyncTest( '`.reel("images")` accepts and normalizes sequence string into an array', function(){
expect(1);
var
selector= '#image',
$reel= $(selector).reel({ frames: 5 }),
entries= {
'img#.jpg': [
'img1.jpg',
'img2.jpg',
'img3.jpg',
'img4.jpg',
'img5.jpg'
]
}
$(document).bind('loaded.test', function(){
$.each(entries, function(ix,it){
$reel.reel('images', ix);
deepEqual( $reel.reel('images'), it, 'Frame '+ix);
});
start();
});
});

asyncTest( 'Positive direction/speed is not detected as reversed', function(){
expect(1);
var
Expand Down

0 comments on commit 91e68a1

Please sign in to comment.