Skip to content

Commit

Permalink
Add autoplay option
Browse files Browse the repository at this point in the history
  • Loading branch information
peachananr committed Nov 6, 2013
1 parent 221fb79 commit 57fd473
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Now call the function and that should be it.
entrance: true, // Entrance Animation. Toggle this to false to turn it off. The default value is true.
preloadImages: true, // Let the script preload all the frames on initial load. Toggle this to false to turn it off. The default value is true.
touchSupport: true, // The script support touch events for mobile phones. If this interferes with your website behaviour, you can toggle this to false. The default value is true.
loading: "Loading.." // This only applies if preloadImages is true. This option let you show a loading indicator while the script is preloading the images. The option accepts HTML. Toggle this to false to turn this off. The default value is "Loading.."
loading: "Loading..", // This only applies if preloadImages is true. This option let you show a loading indicator while the script is preloading the images. The option accepts HTML. Toggle this to false to turn this off. The default value is "Loading.."
autoPlay: false // This option will superseded entrance option. The 3D object will start rotating automatically if autoPlay is not false. This option accepts the speed of the rotation in milliseconds delay. The default value is false.
});
````

Expand Down
36 changes: 30 additions & 6 deletions demo/jquery.interactive_3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
entrance: true,
preloadImages: true,
touchSupport: true,
loading: "Loading.."
loading: "Loading..",
autoPlay: false
};

function touchHandler(event) {
Expand Down Expand Up @@ -123,7 +124,7 @@
el = $(this);
el.find(" > img").addClass("main-frame");
el.drags(settings);
if (settings.entrance == true) {
if (settings.entrance == true && settings.autoPlay == false ) {
var cur_frame = el.find("img.main-frame").attr("src").split('_')[1].split('.')[0];

var x = 0,
Expand Down Expand Up @@ -151,12 +152,17 @@
}

if (x++ < (settings.frames - 1)) {
setTimeout(animate_3d, (x * 1.5));
if (settings.autoPlay != false) {
setTimeout(animate_3d, 0);
} else {
setTimeout(animate_3d, (x * 1.5));
}

}
}


if (settings.loading == false) animate_3d();
if (settings.loading == false && settings.autoPlay == false) animate_3d();
}

if (settings.touchSupport == true) {
Expand Down Expand Up @@ -189,18 +195,36 @@
if (!count) {
el.find(".main-frame").css("visibility", "visible");
el.find(".loading_3d").remove();
animate_3d();
if (settings.autoPlay == false) animate_3d();
}
});
} else {
el.find(".main-frame").css("visibility", "visible");
el.find(".loading_3d").remove();
animate_3d();
if (settings.autoPlay == false) animate_3d();
}
}

}

if (settings.autoPlay != false) {

function intervalTrigger() {
return window.setInterval( function() {
animate_3d();
}, settings.autoPlay );
};

var id = intervalTrigger();

el.mouseenter(function() {
window.clearInterval(id);
}).mouseleave(function() {
id = intervalTrigger();
});

}

}
}(window.jQuery);

2 changes: 1 addition & 1 deletion demo/jquery.interactive_3d.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 30 additions & 6 deletions jquery.interactive_3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
entrance: true,
preloadImages: true,
touchSupport: true,
loading: "Loading.."
loading: "Loading..",
autoPlay: false
};

function touchHandler(event) {
Expand Down Expand Up @@ -123,7 +124,7 @@
el = $(this);
el.find(" > img").addClass("main-frame");
el.drags(settings);
if (settings.entrance == true) {
if (settings.entrance == true && settings.autoPlay == false ) {
var cur_frame = el.find("img.main-frame").attr("src").split('_')[1].split('.')[0];

var x = 0,
Expand Down Expand Up @@ -151,12 +152,17 @@
}

if (x++ < (settings.frames - 1)) {
setTimeout(animate_3d, (x * 1.5));
if (settings.autoPlay != false) {
setTimeout(animate_3d, 0);
} else {
setTimeout(animate_3d, (x * 1.5));
}

}
}


if (settings.loading == false) animate_3d();
if (settings.loading == false && settings.autoPlay == false) animate_3d();
}

if (settings.touchSupport == true) {
Expand Down Expand Up @@ -189,18 +195,36 @@
if (!count) {
el.find(".main-frame").css("visibility", "visible");
el.find(".loading_3d").remove();
animate_3d();
if (settings.autoPlay == false) animate_3d();
}
});
} else {
el.find(".main-frame").css("visibility", "visible");
el.find(".loading_3d").remove();
animate_3d();
if (settings.autoPlay == false) animate_3d();
}
}

}

if (settings.autoPlay != false) {

function intervalTrigger() {
return window.setInterval( function() {
animate_3d();
}, settings.autoPlay );
};

var id = intervalTrigger();

el.mouseenter(function() {
window.clearInterval(id);
}).mouseleave(function() {
id = intervalTrigger();
});

}

}
}(window.jQuery);

Loading

0 comments on commit 57fd473

Please sign in to comment.