Skip to content

Commit 8f71acc

Browse files
committed
Position: Fix initial positioning of cycler demo.
1 parent d32a9e8 commit 8f71acc

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

demos/position/cycler.html

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</style>
1818
<script>
1919
$(function() {
20+
// TODO refactor into a widget and get rid of these plugin methods
2021
$.fn.position2 = function( options ) {
2122
return this.position( $.extend({
2223
of: window,
@@ -52,10 +53,6 @@
5253
});
5354
};
5455

55-
$( "img:eq(0)" ).left();
56-
$( "img:eq(1)" ).center();
57-
$( "img:eq(2)" ).right();
58-
5956
$( "body" ).css({
6057
overflow: "hidden"
6158
})
@@ -66,24 +63,30 @@
6663
position: "absolute",
6764
});
6865

66+
$( "img:eq(0)" ).left();
67+
$( "img:eq(1)" ).center();
68+
$( "img:eq(2)" ).right();
69+
6970
function animate( to ) {
70-
$(this).animate( to );
71+
$(this).stop( true, false ).animate( to );
7172
}
72-
function next() {
73+
function next( event ) {
74+
event.preventDefault();
7375
$( "img:eq(2)" ).center( animate );
7476
$( "img:eq(1)" ).left( animate )
7577
$( "img:eq(0)" ).right().appendTo( ".demo" );
7678
}
77-
function previous() {
79+
function previous( event ) {
80+
event.preventDefault();
7881
$( "img:eq(0)" ).center( animate );
7982
$( "img:eq(1)" ).right( animate );
8083
$( "img:eq(2)" ).left().prependTo( ".demo" );
8184
}
8285
$( "#previous" ).click( previous );
8386
$( "#next" ).click( next );
8487

85-
$( ".demo img" ).click(function() {
86-
$( ".demo img" ).index( this ) === 0 ? previous() : next();
88+
$( ".demo img" ).click(function( event ) {
89+
$( ".demo img" ).index( this ) === 0 ? previous( event ) : next( event );
8790
});
8891

8992
$( window ).resize(function() {
@@ -98,9 +101,9 @@
98101

99102
<div class="demo">
100103

101-
<img src="images/earth.jpg" />
102-
<img src="images/flight.jpg" />
103-
<img src="images/rocket.jpg" />
104+
<img src="images/earth.jpg" width="458" height="308" />
105+
<img src="images/flight.jpg" width="512" height="307" />
106+
<img src="images/rocket.jpg" width="300" height="353" />
104107

105108
<a id="previous" href="#">Previous</a>
106109
<a id="next" href="#">Next</a>

0 commit comments

Comments
 (0)