update caroufredsel

This commit is contained in:
John Bintz 2012-12-14 14:46:46 -05:00
parent 4bcdee1a0e
commit 81bb0c362e
4 changed files with 93 additions and 53 deletions

View File

@ -1,7 +1,8 @@
#= require jquery #= require jquery
#= require caroufredsel/jquery.mousewheel.min #= require caroufredsel/jquery.mousewheel.min
#= require caroufredsel/jquery.touchSwipe.min #= require caroufredsel/jquery.touchSwipe.min
#= require caroufredsel/jquery.carouFredSel-6.0.3 #= require caroufredsel/jquery.ba-throttle-debounce.min
#= require caroufredsel/jquery.carouFredSel-6.1.0
class @Carousel class @Carousel
constructor: (@carousel, options = {}) -> constructor: (@carousel, options = {}) ->

View File

@ -1,5 +1,5 @@
module Caroufredsel module Caroufredsel
module Rails module Rails
VERSION = "0.0.1" VERSION = "6.1.0"
end end
end end

View File

@ -0,0 +1,9 @@
/*
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);

View File

@ -1,5 +1,5 @@
/* /*
* jQuery carouFredSel 6.0.3 * jQuery carouFredSel 6.1.0
* Demo's and documentation: * Demo's and documentation:
* caroufredsel.frebsite.nl * caroufredsel.frebsite.nl
* *
@ -299,7 +299,6 @@
'right' : 'auto', 'right' : 'auto',
'bottom' : 'auto', 'bottom' : 'auto',
'left' : 0, 'left' : 0,
'zIndex' : 1,
'marginTop' : 0, 'marginTop' : 0,
'marginRight' : 0, 'marginRight' : 0,
'marginBottom' : 0, 'marginBottom' : 0,
@ -626,7 +625,14 @@
{ {
if (obj.queue) if (obj.queue)
{ {
$cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]); if (obj.queue == 'last')
{
queu = [];
}
if (obj.queue != 'first' || queu.length == 0)
{
$cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
}
} }
e.stopImmediatePropagation(); e.stopImmediatePropagation();
return debug(conf, 'Carousel currently scrolling.'); return debug(conf, 'Carousel currently scrolling.');
@ -712,13 +718,13 @@
opts.items.visibleConf.old = opts.items.visible; opts.items.visibleConf.old = opts.items.visible;
if (opts.items.visibleConf.variable) if (opts.items.visibleConf.variable)
{ {
var vI = gn_getVisibleItemsNext(a_itm, opts, itms.total-nI); var vI = cf_getItemsAdjust(gn_getVisibleItemsNext(a_itm, opts, itms.total-nI), opts, opts.items.visibleConf.adjust, $tt0);
if (opts.items.visible+nI <= vI && nI < itms.total) if (opts.items.visible+nI <= vI && nI < itms.total)
{ {
nI++; nI++;
vI = gn_getVisibleItemsNext(a_itm, opts, itms.total-nI); vI = cf_getItemsAdjust(gn_getVisibleItemsNext(a_itm, opts, itms.total-nI), opts, opts.items.visibleConf.adjust, $tt0);
} }
opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0); opts.items.visible = vI;
} }
else if (opts.items.filter != '*') else if (opts.items.filter != '*')
{ {
@ -1173,13 +1179,13 @@
opts.items.visibleConf.old = opts.items.visible; opts.items.visibleConf.old = opts.items.visible;
if (opts.items.visibleConf.variable) if (opts.items.visibleConf.variable)
{ {
var vI = gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr); var vI = cf_getItemsAdjust(gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr), opts, opts.items.visibleConf.adjust, $tt0);
while (opts.items.visible-nI >= vI && nI < itms.total) while (opts.items.visible-nI >= vI && nI < itms.total)
{ {
nI++; nI++;
vI = gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr); vI = cf_getItemsAdjust(gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr), opts, opts.items.visibleConf.adjust, $tt0);
} }
opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0); opts.items.visible = vI;
} }
else if (opts.items.filter != '*') else if (opts.items.filter != '*')
{ {
@ -1331,6 +1337,7 @@
case 'crossfade': case 'crossfade':
case 'cover': case 'cover':
case 'cover-fade': case 'cover-fade':
$cfs.css('zIndex', 1);
$cf2.css('zIndex', 0); $cf2.css('zIndex', 0);
break; break;
} }
@ -1429,6 +1436,7 @@
// fire onAfter callbacks // fire onAfter callbacks
_onafter = function() { _onafter = function() {
$cfs.css('zIndex', $cfs.data('_cfs_origCss').zIndex);
sc_afterScroll($cfs, $cf2, sO); sc_afterScroll($cfs, $cf2, sO);
crsl.isScrolling = false; crsl.isScrolling = false;
clbk.onAfter = sc_fireCallbacks($tt0, sO, 'onAfter', cb_arguments, clbk); clbk.onAfter = sc_fireCallbacks($tt0, sO, 'onAfter', cb_arguments, clbk);
@ -1564,13 +1572,15 @@
obj = false; obj = false;
} }
/*
if (crsl.isScrolling) if (crsl.isScrolling)
{ {
if (!is_object(obj) || obj.duration > 0) if (!is_object(obj) || obj.duration > 0)
{ {
return false; // return false;
} }
} }
*/
if (dir != 'prev' && dir != 'next') if (dir != 'prev' && dir != 'next')
{ {
@ -1646,7 +1656,7 @@
s += itms.first; s += itms.first;
if (s != 0) if (s != 0)
{ {
if (items.total > 0) if (itms.total > 0)
{ {
while (s > itms.total) while (s > itms.total)
{ {
@ -1757,7 +1767,7 @@
else else
{ {
num = itms.first; num = itms.first;
itms.first += itm.length itms.first += itm.length;
} }
if (num < 0) if (num < 0)
{ {
@ -1774,17 +1784,6 @@
{ {
num = gn_getItemIndex(num, dev, org, itms, $cfs); num = gn_getItemIndex(num, dev, org, itms, $cfs);
} }
if (orgNum != 'end' && !org)
{
if (num < itms.first)
{
itms.first += itm.length;
}
}
if (itms.first >= itms.total)
{
itms.first -= itms.total;
}
var $cit = $cfs.children().eq(num); var $cit = $cfs.children().eq(num);
if ($cit.length) if ($cit.length)
@ -1793,10 +1792,22 @@
} }
else else
{ {
debug(conf, 'Correct insert-position not found! Appending item to the end.');
$cfs.append(itm); $cfs.append(itm);
} }
if (orgNum != 'end' && !org)
{
if (num < itms.first)
{
itms.first += itm.length;
}
}
itms.total = $cfs.children().length; itms.total = $cfs.children().length;
if (itms.first >= itms.total)
{
itms.first -= itms.total;
}
$cfs.trigger(cf_e('updateSizes', conf)); $cfs.trigger(cf_e('updateSizes', conf));
$cfs.trigger(cf_e('linkAnchors', conf)); $cfs.trigger(cf_e('linkAnchors', conf));
@ -2157,12 +2168,17 @@
avail_primary = ms_getParentSize($wrp, opts, 'width'); avail_primary = ms_getParentSize($wrp, opts, 'width');
itms.total = a_itm.length; itms.total = a_itm.length;
opts.maxDimension = ms_getMaxDimension(opts, avail_primary);
if (crsl.primarySizePercentage) if (crsl.primarySizePercentage)
{ {
opts.maxDimension = avail_primary;
opts[opts.d['width']] = ms_getPercentage(avail_primary, crsl.primarySizePercentage); opts[opts.d['width']] = ms_getPercentage(avail_primary, crsl.primarySizePercentage);
} }
else
{
opts.maxDimension = ms_getMaxDimension(opts, avail_primary);
}
if (opts.responsive) if (opts.responsive)
{ {
opts.items.width = opts.items.sizesConf.width; opts.items.width = opts.items.sizesConf.width;
@ -2515,31 +2531,45 @@
if (crsl.upDateOnWindowResize) if (crsl.upDateOnWindowResize)
{ {
var $w = $(window), var resizeFn = function(e) {
_windowWidth = 0, $cfs.trigger(cf_e('finish', conf));
_windowHeight = 0; if (opts.auto.pauseOnResize && !crsl.isPaused)
$w.bind(cf_e('resize', conf, false, true, true), function(e) {
var nw = $w.width(),
nh = $w.height();
if (nw != _windowWidth || nh != _windowHeight)
{ {
$cfs.trigger(cf_e('play', conf));
$cfs.trigger(cf_e('finish', conf));
if (opts.auto.pauseOnResize && !crsl.isPaused)
{
$cfs.trigger(cf_e('play', conf));
}
sz_resetMargin($cfs.children(), opts);
$cfs.trigger(cf_e('updateSizes', conf));
_windowWidth = nw;
_windowHeight = nh;
} }
}); sz_resetMargin($cfs.children(), opts);
$cfs.trigger(cf_e('updateSizes', conf));
};
var $w = $(window),
onResize = null;
if ($.debounce && conf.onWindowResize == 'debounce')
{
onResize = $.debounce(200, resizeFn);
}
else if ($.throttle && conf.onWindowResize == 'throttle')
{
onResize = $.throttle(300, resizeFn);
}
else
{
var _windowWidth = 0,
_windowHeight = 0;
onResize = function() {
var nw = $w.width(),
nh = $w.height();
if (nw != _windowWidth || nh != _windowHeight)
{
resizeFn();
_windowWidth = nw;
_windowHeight = nh;
}
};
}
$w.bind(cf_e('resize', conf, false, true, true), onResize);
} }
}; // /bind_buttons }; // /bind_buttons
@ -2739,6 +2769,7 @@
}; };
$.fn.carouFredSel.configs = { $.fn.carouFredSel.configs = {
'debug' : false, 'debug' : false,
'onWindowResize': 'throttle',
'events' : { 'events' : {
'prefix' : '', 'prefix' : '',
'namespace' : 'cfs' 'namespace' : 'cfs'
@ -2931,12 +2962,11 @@
'items': { 'items': {
'old': i_old, 'old': i_old,
'skipped': i_skp, 'skipped': i_skp,
'visible': i_new,
// DEPRECATED // DEPRECATED
'new': i_new, 'new': i_new
// /DEPRECATED // /DEPRECATED
'visible': i_new
}, },
'scroll': { 'scroll': {
'items': s_itm, 'items': s_itm,