return size;
};
+/**
+ * Behaves the same as setInterval except uses requestAnimationFrame() where possible for better performance
+ * @param {function} fn The callback function
+ * @param {int} delay The delay in milliseconds
+ */
+window.requestInterval = function(fn, delay) {
+ var start = new Date().getTime(),
+ handle = new Object();
+
+ function loop() {
+ var current = new Date().getTime(),
+ delta = current - start;
+
+ if(delta >= delay) {
+ fn.call();
+ start = new Date().getTime();
+ }
+
+ handle.value = requestAnimationFrame(loop);
+ };
+
+ handle.value = requestAnimationFrame(loop);
+ return handle;
+}
+
+/**
+ * Behaves the same as clearInterval except uses cancelRequestAnimationFrame() where possible for better performance
+ * @param {int|object} fn The callback function
+ */
+window.clearRequestInterval = function(handle) {
+ window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
+ window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
+ window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : /* Support for legacy API */
+ window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
+ window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
+ window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
+ clearInterval(handle);
+};
+
+window.requestTimeout = function(fn, delay) {
+
+ var start = new Date().getTime(),
+ handle = new Object();
+
+ function loop(){
+ var current = new Date().getTime(),
+ delta = current - start;
+
+ delta >= delay ? fn.call() : handle.value = requestAnimationFrame(loop);
+ };
+
+ handle.value = requestAnimationFrame(loop);
+ return handle;
+};
+
+/**
+ * Behaves the same as clearTimeout except uses cancelRequestAnimationFrame() where possible for better performance
+ * @param {int|object} fn The callback function
+ */
+window.clearRequestTimeout = function(handle) {
+ window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
+ window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) :
+ window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : /* Support for legacy API */
+ window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
+ window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
+ window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) :
+ clearTimeout(handle);
+};
+
/*! sprintf-js v1.1.2 | Copyright (c) 2007-present, Alexandru Mărășteanu <hello@alexei.ro> | BSD-3-Clause */
!function () {
"use strict";
function FluidbookDummySlideshow(fluidbook) {
this.fluidbook = fluidbook;
- this.intervals = [];
+
}
FluidbookDummySlideshow.prototype = {
clear: function () {
- // console.log('clear');
- // $.each(this.intervals, function (k, v) {
- // clearInterval(v);
- // });
},
initSlideshow: function (s) {
// Move first to end
holder.append(holder.find('.fb-slideshow-slide:eq(0)'));
-
- this.intervals.push(
- setInterval(
- function () {
- if(!$(holder).is(':visible')){
- return;
- }
- var current = holder.find('.fb-slideshow-slide.show').eq(0);
- var next = $(current).nextAll('.fb-slideshow-slide:not(.show):eq(0)');
- if ($(next).length === 0) {
- next = holder.find('.fb-slideshow-slide:eq(0)');
- }
-
- $(next).css({display: 'block', zIndex: 2});
-
- setTimeout(function () {
- $(next).addClass('show').one($this.fluidbook.support.getTransitionEndEvent(), function () {
- $(current).removeClass('show').css('display', 'none');
- $(this).css({zIndex: ''});
- });
- }, 200);
-
+ requestInterval(
+ function () {
+ if (!$(holder).is(':visible')) {
+ return;
+ }
+ var current = holder.find('.fb-slideshow-slide.show').eq(0);
+ var next = $(current).nextAll('.fb-slideshow-slide:not(.show):eq(0)');
+ if ($(next).length === 0) {
+ next = holder.find('.fb-slideshow-slide:eq(0)');
}
- , parseFloat(this.fluidbook.settings.inlineSlideshowDuration) * 1000)
- );
+ $(next).css({display: 'block', zIndex: 2});
+ requestTimeout(function () {
+ $(next).addClass('show').one($this.fluidbook.support.getTransitionEndEvent(), function () {
+ $(holder).find('.fb-slideshow-slide.show').not(next).removeClass('show').css('display', 'none');
+ $(this).css({zIndex: '', display: ''});
+ });
+ }, 200);
+ }, parseFloat(this.fluidbook.settings.inlineSlideshowDuration) * 1000);
},
resizeInline() {