flux.js 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582
  1. /**
  2. * @preserve Flux Slider v1.4.4
  3. * http://www.joelambert.co.uk/flux
  4. *
  5. * Copyright 2011, Joe Lambert.
  6. * Free to use under the MIT license.
  7. * http://www.opensource.org/licenses/mit-license.php
  8. */
  9. // Flux namespace
  10. window.flux = {
  11. version: '1.4.4'
  12. };
  13. (function($){
  14. flux.slider = function(elem, opts) {
  15. // Setup the flux.browser singleton to perform feature detection
  16. flux.browser.init();
  17. if(!flux.browser.supportsTransitions)
  18. {
  19. if(window.console && window.console.error)
  20. console.error("Flux Slider requires a browser that supports CSS3 transitions");
  21. }
  22. var _this = this;
  23. this.element = $(elem);
  24. // Make a list of all available transitions
  25. this.transitions = [];
  26. for(var fx in flux.transitions)
  27. this.transitions.push(fx);
  28. this.options = $.extend({
  29. autoplay: true,
  30. transitions: this.transitions,
  31. delay: 4000,
  32. pagination: true,
  33. controls: false,
  34. captions: false,
  35. width: null,
  36. height: null,
  37. onTransitionEnd: null
  38. }, opts);
  39. // Set the height/width if given [EXPERIMENTAL!]
  40. this.height = this.options.height ? this.options.height : null;
  41. this.width = this.options.width ? this.options.width : null;
  42. // Filter out non compatible transitions
  43. var newTrans = [];
  44. $(this.options.transitions).each(function(index, tran){
  45. var t = new flux.transitions[tran](this),
  46. compatible = true;
  47. if(t.options.requires3d && !flux.browser.supports3d)
  48. compatible = false;
  49. if(t.options.compatibilityCheck)
  50. compatible = t.options.compatibilityCheck();
  51. if(compatible)
  52. newTrans.push(tran);
  53. });
  54. this.options.transitions = newTrans;
  55. this.images = new Array();
  56. this.imageLoadedCount = 0;
  57. this.currentImageIndex = 0;
  58. this.nextImageIndex = 1;
  59. this.playing = false;
  60. this.container = $('<div class="fluxslider"></div>').appendTo(this.element);
  61. this.surface = $('<div class="surface" style="position: relative"></div>').appendTo(this.container);
  62. // Listen for click events as we may want to follow a link
  63. this.container.bind('click', function(event) {
  64. if($(event.target).hasClass('hasLink'))
  65. window.location = $(event.target).data('href');
  66. });
  67. this.imageContainer = $('<div class="images loading"></div>').css({
  68. 'position': 'relative',
  69. 'overflow': 'hidden',
  70. 'min-height': '100px'
  71. }).appendTo(this.surface);
  72. // If the height/width is already set then resize the container
  73. if(this.width && this.height)
  74. {
  75. this.imageContainer.css({
  76. width: this.width+'px',
  77. height: this.height+'px'
  78. });
  79. }
  80. // Create the placeholders for the current and next image
  81. this.image1 = $('<div class="image1" style="height: 100%; width: 100%"></div>').appendTo(this.imageContainer);
  82. this.image2 = $('<div class="image2" style="height: 100%; width: 100%"></div>').appendTo(this.imageContainer);
  83. $(this.image1).add(this.image2).css({
  84. 'position': 'absolute',
  85. 'top': '0px',
  86. 'left': '0px'
  87. });
  88. // Get a list of the images to use
  89. this.element.find('img, a img').each(function(index, found_img){
  90. var imgClone = found_img.cloneNode(false),
  91. link = $(found_img).parent();
  92. // If this img is directly inside a link then save the link for later use
  93. if(link.is('a'))
  94. $(imgClone).data('href', link.attr('href'));
  95. _this.images.push(imgClone);
  96. // Remove the images from the DOM
  97. $(found_img).remove();
  98. });
  99. // Load the images afterwards as IE seems to load images synchronously
  100. for(var i=0; i<this.images.length; i++) {
  101. var image = new Image();
  102. image.onload = function() {
  103. _this.imageLoadedCount++;
  104. _this.width = _this.width ? _this.width : this.width;
  105. _this.height = _this.height ? _this.height : this.height;
  106. if(_this.imageLoadedCount >= _this.images.length)
  107. {
  108. _this.finishedLoading();
  109. _this.setupImages();
  110. }
  111. };
  112. // Load the image to ensure its cached by the browser
  113. image.src = this.images[i].src;
  114. }
  115. // Catch when a transition has finished
  116. this.element.bind('fluxTransitionEnd', function(event, data) {
  117. // If the slider is currently playing then set the timeout for the next transition
  118. // if(_this.isPlaying())
  119. // _this.start();
  120. // Are we using a callback instead of events for notifying about transition ends?
  121. if(_this.options.onTransitionEnd) {
  122. event.preventDefault();
  123. _this.options.onTransitionEnd(data);
  124. }
  125. });
  126. // Should we auto start the slider?
  127. if(this.options.autoplay)
  128. this.start();
  129. // Handle swipes
  130. this.element.bind('swipeLeft', function(event){
  131. _this.next(null, {direction: 'left'});
  132. }).bind('swipeRight', function(event){
  133. _this.prev(null, {direction: 'right'});
  134. });
  135. // Under FF7 autoplay breaks when the current tab loses focus
  136. setTimeout(function(){
  137. $(window).focus(function(){
  138. if(_this.isPlaying())
  139. _this.next();
  140. });
  141. }, 100);
  142. };
  143. flux.slider.prototype = {
  144. constructor: flux.slider,
  145. playing: false,
  146. start: function() {
  147. var _this = this;
  148. this.playing = true;
  149. this.interval = setInterval(function() {
  150. console.log('play');
  151. _this.transition();
  152. }, this.options.delay);
  153. },
  154. stop: function() {
  155. this.playing = false;
  156. clearInterval(this.interval);
  157. this.interval = null;
  158. },
  159. isPlaying: function() {
  160. return this.playing;
  161. //return this.interval != null;
  162. },
  163. next: function(trans, opts) {
  164. opts = opts || {};
  165. opts.direction = 'left';
  166. this.showImage(this.currentImageIndex+1, trans, opts);
  167. },
  168. prev: function(trans, opts) {
  169. opts = opts || {};
  170. opts.direction = 'right';
  171. this.showImage(this.currentImageIndex-1, trans, opts);
  172. },
  173. showImage: function(index, trans, opts) {
  174. this.setNextIndex(index);
  175. // Temporarily stop the transition interval
  176. //clearInterval(this.interval);
  177. //this.interval = null;
  178. this.setupImages();
  179. this.transition(trans, opts);
  180. },
  181. finishedLoading: function() {
  182. var _this = this;
  183. this.container.css({
  184. width: this.width+'px',
  185. height: this.height+'px'
  186. });
  187. this.imageContainer.removeClass('loading');
  188. // Should we setup a pagination view?
  189. if(this.options.pagination)
  190. {
  191. // TODO: Attach to touch events if appropriate
  192. this.pagination = $('<ul class="pagination"></ul>').css({
  193. margin: '0px',
  194. padding: '0px',
  195. 'text-align': 'center'
  196. });
  197. this.pagination.bind('click', function(event){
  198. event.preventDefault();
  199. _this.showImage($(event.target).data('index'));
  200. });
  201. $(this.images).each(function(index, image){
  202. var li = $('<li data-index="'+index+'">'+(index+1)+'</li>').css({
  203. display: 'inline-block',
  204. 'margin-left': '0.5em',
  205. 'cursor': 'pointer'
  206. }).appendTo(_this.pagination);
  207. if(index == 0)
  208. li.css('margin-left', 0).addClass('current');
  209. });
  210. this.container.append(this.pagination);
  211. }
  212. // Resize
  213. $(this.imageContainer).css({
  214. width: this.width+'px',
  215. height: this.height+'px'
  216. });
  217. $(this.image1).css({
  218. width: this.width+'px',
  219. height: this.height+'px'
  220. });
  221. $(this.image2).css({
  222. width: this.width+'px',
  223. height: this.height+'px'
  224. });
  225. this.container.css({
  226. width: this.width+'px',
  227. height: this.height+(this.options.pagination?this.pagination.height():0)+'px'
  228. });
  229. // Should we add prev/next controls?
  230. if(this.options.controls)
  231. {
  232. var css = {
  233. padding: '4px 10px 10px',
  234. 'font-size': '60px',
  235. 'font-family': 'arial, sans-serif',
  236. 'line-height': '1em',
  237. 'font-weight': 'bold',
  238. color: '#FFF',
  239. 'text-decoration': 'none',
  240. background: 'rgba(0,0,0,0.5)',
  241. position: 'absolute',
  242. 'z-index': 2000
  243. };
  244. this.nextButton = $('<a href="#">»</a>').css(css).css3({
  245. 'border-radius': '4px'
  246. }).appendTo(this.surface).bind('click', function(event){
  247. event.preventDefault();
  248. _this.next();
  249. });
  250. this.prevButton = $('<a href="#">«</a>').css(css).css3({
  251. 'border-radius': '4px'
  252. }).appendTo(this.surface).bind('click', function(event){
  253. event.preventDefault();
  254. _this.prev();
  255. });
  256. var top = (this.height - this.nextButton.height())/2;
  257. this.nextButton.css({
  258. top: top+'px',
  259. right: '10px'
  260. });
  261. this.prevButton.css({
  262. top: top+'px',
  263. left: '10px'
  264. });
  265. }
  266. // Should we use captions?
  267. if(this.options.captions)
  268. {
  269. this.captionBar = $('<div class="caption"></div>').css({
  270. background: 'rgba(0,0,0,0.6)',
  271. color: '#FFF',
  272. 'font-size': '16px',
  273. 'font-family': 'helvetica, arial, sans-serif',
  274. 'text-decoration': 'none',
  275. 'font-weight': 'bold',
  276. padding: '1.5em 1em',
  277. opacity: 0,
  278. position: 'absolute',
  279. 'z-index': 110,
  280. width: '100%',
  281. bottom: 0
  282. }).css3({
  283. 'transition-property': 'opacity',
  284. 'transition-duration': '800ms',
  285. 'box-sizing': 'border-box'
  286. }).prependTo(this.surface);
  287. }
  288. this.updateCaption();
  289. },
  290. setupImages: function() {
  291. var img1 = this.getImage(this.currentImageIndex),
  292. css1 = {
  293. 'background-image': 'url("'+img1.src+'")',
  294. 'z-index': 101,
  295. 'cursor': 'auto'
  296. };
  297. // Does this image have an associated link?
  298. if($(img1).data('href'))
  299. {
  300. css1.cursor = 'pointer';
  301. this.image1.addClass('hasLink');
  302. this.image1.data('href', $(img1).data('href'));
  303. }
  304. else
  305. {
  306. this.image1.removeClass('hasLink');
  307. this.image1.data('href', null);
  308. }
  309. this.image1.css(css1).children().remove();
  310. this.image2.css({
  311. 'background-image': 'url("'+this.getImage(this.nextImageIndex).src+'")',
  312. 'z-index': 100
  313. }).show();
  314. if(this.options.pagination && this.pagination)
  315. {
  316. this.pagination.find('li.current').removeClass('current');
  317. $(this.pagination.find('li')[this.currentImageIndex]).addClass('current');
  318. }
  319. },
  320. transition: function(transition, opts) {
  321. // Allow a transition to be picked from ALL available transitions (not just the reduced set)
  322. if(transition == undefined || !flux.transitions[transition])
  323. {
  324. // Pick a transition at random from the (possibly reduced set of) transitions
  325. var index = Math.floor(Math.random()*(this.options.transitions.length));
  326. transition = this.options.transitions[index];
  327. }
  328. var tran = null;
  329. try {
  330. tran = new flux.transitions[transition](this, $.extend(this.options[transition] ? this.options[transition] : {}, opts));
  331. }
  332. catch(e) {
  333. // If an invalid transition has been provided then use the fallback (default is to just switch the image)
  334. tran = new flux.transition(this, {fallback: true});
  335. }
  336. tran.run();
  337. this.currentImageIndex = this.nextImageIndex;
  338. this.setNextIndex(this.currentImageIndex+1);
  339. this.updateCaption();
  340. },
  341. updateCaption: function() {
  342. var str = $(this.getImage(this.currentImageIndex)).attr('title');
  343. if(this.options.captions && this.captionBar)
  344. {
  345. if(str !== "")
  346. this.captionBar.html(str);
  347. this.captionBar.css('opacity', str === "" ? 0 : 1);
  348. }
  349. },
  350. getImage: function(index) {
  351. index = index % this.images.length;
  352. return this.images[index];
  353. },
  354. setNextIndex: function(nextIndex)
  355. {
  356. if(nextIndex == undefined)
  357. nextIndex = this.currentImageIndex+1;
  358. this.nextImageIndex = nextIndex;
  359. if(this.nextImageIndex > this.images.length-1)
  360. this.nextImageIndex = 0;
  361. if(this.nextImageIndex < 0)
  362. this.nextImageIndex = this.images.length-1;
  363. },
  364. increment: function() {
  365. this.currentImageIndex++;
  366. if(this.currentImageIndex > this.images.length-1)
  367. this.currentImageIndex = 0;
  368. }
  369. };
  370. })(window.jQuery || window.Zepto);
  371. /**
  372. * Helper object to determine support for various CSS3 functions
  373. * @author Joe Lambert
  374. */
  375. (function($) {
  376. flux.browser = {
  377. init: function() {
  378. // Have we already been initialised?
  379. if(flux.browser.supportsTransitions !== undefined)
  380. return;
  381. var div = document.createElement('div'),
  382. prefixes = ['-webkit', '-moz', '-o', '-ms'],
  383. domPrefixes = ['Webkit', 'Moz', 'O', 'Ms'];
  384. // Does the current browser support CSS Transitions?
  385. if(window.Modernizr && Modernizr.csstransitions !== undefined)
  386. flux.browser.supportsTransitions = Modernizr.csstransitions;
  387. else
  388. {
  389. flux.browser.supportsTransitions = this.supportsCSSProperty('Transition');
  390. }
  391. // Does the current browser support 3D CSS Transforms?
  392. if(window.Modernizr && Modernizr.csstransforms3d !== undefined)
  393. flux.browser.supports3d = Modernizr.csstransforms3d;
  394. else
  395. {
  396. // Custom detection when Modernizr isn't available
  397. flux.browser.supports3d = this.supportsCSSProperty("Perspective");
  398. if ( flux.browser.supports3d && 'webkitPerspective' in $('body').get(0).style ) {
  399. // Double check with a media query (similar to how Modernizr does this)
  400. var div3D = $('<div id="csstransform3d"></div>');
  401. var mq = $('<style media="(transform-3d), ('+prefixes.join('-transform-3d),(')+'-transform-3d)">div#csstransform3d { position: absolute; left: 9px }</style>');
  402. $('body').append(div3D);
  403. $('head').append(mq);
  404. flux.browser.supports3d = div3D.get(0).offsetLeft == 9;
  405. div3D.remove();
  406. mq.remove();
  407. }
  408. }
  409. },
  410. supportsCSSProperty: function(prop) {
  411. var div = document.createElement('div'),
  412. prefixes = ['-webkit', '-moz', '-o', '-ms'],
  413. domPrefixes = ['Webkit', 'Moz', 'O', 'Ms'];
  414. var support = false;
  415. for(var i=0; i<domPrefixes.length; i++)
  416. {
  417. if(domPrefixes[i]+prop in div.style)
  418. support = support || true;
  419. }
  420. return support;
  421. },
  422. translate: function(x, y, z) {
  423. x = (x != undefined) ? x : 0;
  424. y = (y != undefined) ? y : 0;
  425. z = (z != undefined) ? z : 0;
  426. return 'translate' + (flux.browser.supports3d ? '3d(' : '(') + x + 'px,' + y + (flux.browser.supports3d ? 'px,' + z + 'px)' : 'px)');
  427. },
  428. rotateX: function(deg) {
  429. return flux.browser.rotate('x', deg);
  430. },
  431. rotateY: function(deg) {
  432. return flux.browser.rotate('y', deg);
  433. },
  434. rotateZ: function(deg) {
  435. return flux.browser.rotate('z', deg);
  436. },
  437. rotate: function(axis, deg) {
  438. if(!axis in {'x':'', 'y':'', 'z':''})
  439. axis = 'z';
  440. deg = (deg != undefined) ? deg : 0;
  441. if(flux.browser.supports3d)
  442. return 'rotate3d('+(axis == 'x' ? '1' : '0')+', '+(axis == 'y' ? '1' : '0')+', '+(axis == 'z' ? '1' : '0')+', '+deg+'deg)';
  443. else
  444. {
  445. if(axis == 'z')
  446. return 'rotate('+deg+'deg)';
  447. else
  448. return '';
  449. }
  450. }
  451. };
  452. $(function(){
  453. // To continue to work with legacy code, ensure that flux.browser is initialised on document ready at the latest
  454. flux.browser.init();
  455. });
  456. })(window.jQuery || window.Zepto);
  457. (function($){
  458. /**
  459. * Helper function for cross-browser CSS3 support, prepends all possible prefixes to all properties passed in
  460. * @param {Object} props Ker/value pairs of CSS3 properties
  461. */
  462. $.fn.css3 = function(props) {
  463. var css = {};
  464. var prefixes = ['webkit', 'moz', 'ms', 'o'];
  465. for(var prop in props)
  466. {
  467. // Add the vendor specific versions
  468. for(var i=0; i<prefixes.length; i++)
  469. css['-'+prefixes[i]+'-'+prop] = props[prop];
  470. // Add the actual version
  471. css[prop] = props[prop];
  472. }
  473. this.css(css);
  474. return this;
  475. };
  476. /**
  477. * Helper function to bind to the correct transition end event
  478. * @param {function} callback The function to call when the event fires
  479. */
  480. $.fn.transitionEnd = function(callback) {
  481. var _this = this;
  482. var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd'];
  483. for(var i=0; i < events.length; i++)
  484. {
  485. this.bind(events[i], function(event){
  486. // Automatically stop listening for the event
  487. for(var j=0; j<events.length;j++)
  488. $(this).unbind(events[j]);
  489. // Perform the callback function
  490. if(callback)
  491. callback.call(this, event);
  492. });
  493. }
  494. return this;
  495. };
  496. flux.transition = function(fluxslider, opts) {
  497. this.options = $.extend({
  498. requires3d: false,
  499. after: function() {
  500. // Default callback for after the transition has completed
  501. }
  502. }, opts);
  503. this.slider = fluxslider;
  504. // We need to ensure transitions degrade gracefully if the transition is unsupported or not loaded
  505. if((this.options.requires3d && !flux.browser.supports3d) || !flux.browser.supportsTransitions || this.options.fallback === true)
  506. {
  507. var _this = this;
  508. this.options.after = undefined;
  509. this.options.setup = function() {
  510. //console.error("Fallback setup()");
  511. _this.fallbackSetup();
  512. };
  513. this.options.execute = function() {
  514. //console.error("Fallback execute()");
  515. _this.fallbackExecute();
  516. };
  517. }
  518. };
  519. flux.transition.prototype = {
  520. constructor: flux.transition,
  521. hasFinished: false, // This is a lock to ensure that the fluxTransitionEnd event is only fired once per tansition
  522. run: function() {
  523. var _this = this;
  524. // do something
  525. if(this.options.setup !== undefined)
  526. this.options.setup.call(this);
  527. // Remove the background image from the top image
  528. this.slider.image1.css({
  529. 'background-image': 'none'
  530. });
  531. this.slider.imageContainer.css('overflow', this.options.requires3d ? 'visible' : 'hidden');
  532. // For some of the 3D effects using Zepto we need to delay the transitions for some reason
  533. setTimeout(function(){
  534. if(_this.options.execute !== undefined)
  535. _this.options.execute.call(_this);
  536. }, 5);
  537. },
  538. finished: function() {
  539. if(this.hasFinished)
  540. return;
  541. this.hasFinished = true;
  542. if(this.options.after)
  543. this.options.after.call(this);
  544. this.slider.imageContainer.css('overflow', 'hidden');
  545. this.slider.setupImages();
  546. // Trigger an event to signal the end of a transition
  547. this.slider.element.trigger('fluxTransitionEnd', {
  548. currentImage: this.slider.getImage(this.slider.currentImageIndex)
  549. });
  550. },
  551. fallbackSetup: function() {
  552. },
  553. fallbackExecute: function() {
  554. this.finished();
  555. }
  556. };
  557. flux.transitions = {};
  558. // Flux grid transition
  559. flux.transition_grid = function(fluxslider, opts) {
  560. return new flux.transition(fluxslider, $.extend({
  561. columns: 6,
  562. rows: 6,
  563. forceSquare: false,
  564. setup: function() {
  565. var imgWidth = this.slider.image1.width(),
  566. imgHeight = this.slider.image1.height();
  567. var colWidth = Math.floor(imgWidth / this.options.columns),
  568. rowHeight = Math.floor(imgHeight / this.options.rows);
  569. if(this.options.forceSquare)
  570. {
  571. rowHeight = colWidth;
  572. this.options.rows = Math.floor(imgHeight / rowHeight);
  573. }
  574. // Work out how much space remains with the adjusted barWidth
  575. var colRemainder = imgWidth - (this.options.columns * colWidth),
  576. colAddPerLoop = Math.ceil(colRemainder / this.options.columns),
  577. rowRemainder = imgHeight - (this.options.rows * rowHeight),
  578. rowAddPerLoop = Math.ceil(rowRemainder / this.options.rows),
  579. delayBetweenBars = 150,
  580. height = this.slider.image1.height(),
  581. totalLeft = 0,
  582. totalTop = 0,
  583. fragment = document.createDocumentFragment();
  584. for(var i=0; i<this.options.columns; i++) {
  585. var thisColWidth = colWidth,
  586. totalTop = 0;
  587. if(colRemainder > 0)
  588. {
  589. var add = colRemainder >= colAddPerLoop ? colAddPerLoop : colRemainder;
  590. thisColWidth += add;
  591. colRemainder -= add;
  592. }
  593. for(var j=0; j<this.options.rows; j++)
  594. {
  595. var thisRowHeight = rowHeight,
  596. thisRowRemainder = rowRemainder;
  597. if(thisRowRemainder > 0)
  598. {
  599. var add = thisRowRemainder >= rowAddPerLoop ? rowAddPerLoop : thisRowRemainder;
  600. thisRowHeight += add;
  601. thisRowRemainder -= add;
  602. }
  603. var tile = $('<div class="tile tile-'+i+'-'+j+'"></div>').css({
  604. width: thisColWidth+'px',
  605. height: thisRowHeight+'px',
  606. position: 'absolute',
  607. top: totalTop+'px',
  608. left: totalLeft+'px'
  609. });
  610. this.options.renderTile.call(this, tile, i, j, thisColWidth, thisRowHeight, totalLeft, totalTop);
  611. fragment.appendChild(tile.get(0));
  612. totalTop += thisRowHeight;
  613. }
  614. totalLeft += thisColWidth;
  615. }
  616. // Append the fragement to the surface
  617. this.slider.image1.get(0).appendChild(fragment);
  618. },
  619. execute: function() {
  620. var _this = this,
  621. height = this.slider.image1.height(),
  622. bars = this.slider.image1.find('div.barcontainer');
  623. this.slider.image2.hide();
  624. // Get notified when the last transition has completed
  625. bars.last().transitionEnd(function(event){
  626. _this.slider.image2.show();
  627. _this.finished();
  628. });
  629. bars.css3({
  630. 'transform': flux.browser.rotateX(-90) + ' ' + flux.browser.translate(0, height/2, height/2)
  631. });
  632. },
  633. renderTile: function(elem, colIndex, rowIndex, colWidth, rowHeight, leftOffset, topOffset) {
  634. }
  635. }, opts));
  636. };
  637. })(window.jQuery || window.Zepto);
  638. (function($) {
  639. flux.transitions.bars = function(fluxslider, opts) {
  640. return new flux.transition_grid(fluxslider, $.extend({
  641. columns: 10,
  642. rows: 1,
  643. delayBetweenBars: 40,
  644. renderTile: function(elem, colIndex, rowIndex, colWidth, rowHeight, leftOffset, topOffset) {
  645. $(elem).css({
  646. 'background-image': this.slider.image1.css('background-image'),
  647. 'background-position': '-'+leftOffset+'px 0px'
  648. }).css3({
  649. 'transition-duration': '400ms',
  650. 'transition-timing-function': 'ease-in',
  651. 'transition-property': 'all',
  652. 'transition-delay': (colIndex*this.options.delayBetweenBars)+'ms'
  653. });
  654. },
  655. execute: function() {
  656. var _this = this;
  657. var height = this.slider.image1.height();
  658. var bars = this.slider.image1.find('div.tile');
  659. // Get notified when the last transition has completed
  660. $(bars[bars.length-1]).transitionEnd(function(){
  661. _this.finished();
  662. });
  663. setTimeout(function(){
  664. bars.css({
  665. 'opacity': '0.5'
  666. }).css3({
  667. 'transform': flux.browser.translate(0, height)
  668. });
  669. }, 50);
  670. }
  671. }, opts));
  672. };
  673. })(window.jQuery || window.Zepto);
  674. (function($) {
  675. flux.transitions.bars3d = function(fluxslider, opts) {
  676. return new flux.transition_grid(fluxslider, $.extend({
  677. requires3d: true,
  678. columns: 7,
  679. rows: 1,
  680. delayBetweenBars: 150,
  681. perspective: 1000,
  682. renderTile: function(elem, colIndex, rowIndex, colWidth, rowHeight, leftOffset, topOffset) {
  683. var bar = $('<div class="bar-'+colIndex+'"></div>').css({
  684. width: colWidth+'px',
  685. height: '100%',
  686. position: 'absolute',
  687. top: '0px',
  688. left: '0px',
  689. 'z-index': 200,
  690. 'background-image': this.slider.image1.css('background-image'),
  691. 'background-position': '-'+leftOffset+'px 0px',
  692. 'background-repeat': 'no-repeat'
  693. }).css3({
  694. 'backface-visibility': 'hidden'
  695. }),
  696. bar2 = $(bar.get(0).cloneNode(false)).css({
  697. 'background-image': this.slider.image2.css('background-image')
  698. }).css3({
  699. 'transform': flux.browser.rotateX(90) + ' ' + flux.browser.translate(0, -rowHeight/2, rowHeight/2)
  700. }),
  701. left = $('<div class="side bar-'+colIndex+'"></div>').css({
  702. width: rowHeight+'px',
  703. height: rowHeight+'px',
  704. position: 'absolute',
  705. top: '0px',
  706. left: '0px',
  707. background: '#222',
  708. 'z-index': 190
  709. }).css3({
  710. 'transform': flux.browser.rotateY(90) + ' ' + flux.browser.translate(rowHeight/2, 0, -rowHeight/2) + ' ' + flux.browser.rotateY(180),
  711. 'backface-visibility': 'hidden'
  712. }),
  713. right = $(left.get(0).cloneNode(false)).css3({
  714. 'transform': flux.browser.rotateY(90) + ' ' + flux.browser.translate(rowHeight/2, 0, colWidth-rowHeight/2)
  715. });
  716. $(elem).css({
  717. width: colWidth+'px',
  718. height: '100%',
  719. position: 'absolute',
  720. top: '0px',
  721. left: leftOffset+'px',
  722. 'z-index': colIndex > this.options.columns/2 ? 1000-colIndex : 1000 // Fix for Chrome to ensure that the z-index layering is correct!
  723. }).css3({
  724. 'transition-duration': '800ms',
  725. 'transition-timing-function': 'linear',
  726. 'transition-property': 'all',
  727. 'transition-delay': (colIndex*this.options.delayBetweenBars)+'ms',
  728. 'transform-style': 'preserve-3d'
  729. }).append(bar).append(bar2).append(left).append(right);
  730. },
  731. execute: function() {
  732. this.slider.image1.css3({
  733. 'perspective': this.options.perspective,
  734. 'perspective-origin': '50% 50%'
  735. }).css({
  736. '-moz-transform': 'perspective('+this.options.perspective+'px)',
  737. '-moz-perspective': 'none',
  738. '-moz-transform-style': 'preserve-3d'
  739. });
  740. var _this = this,
  741. height = this.slider.image1.height(),
  742. bars = this.slider.image1.find('div.tile');
  743. this.slider.image2.hide();
  744. // Get notified when the last transition has completed
  745. bars.last().transitionEnd(function(event){
  746. _this.slider.image1.css3({
  747. 'transform-style': 'flat'
  748. });
  749. _this.slider.image2.show();
  750. _this.finished();
  751. });
  752. setTimeout(function(){
  753. bars.css3({
  754. 'transform': flux.browser.rotateX(-90) + ' ' + flux.browser.translate(0, height/2, height/2)
  755. });
  756. }, 50);
  757. }
  758. }, opts));
  759. };
  760. })(window.jQuery || window.Zepto);
  761. (function($) {
  762. flux.transitions.blinds = function(fluxslider, opts) {
  763. return new flux.transitions.bars(fluxslider, $.extend({
  764. execute: function() {
  765. var _this = this;
  766. var height = this.slider.image1.height();
  767. var bars = this.slider.image1.find('div.tile');
  768. // Get notified when the last transition has completed
  769. $(bars[bars.length-1]).transitionEnd(function(){
  770. _this.finished();
  771. });
  772. setTimeout(function(){
  773. bars.css({
  774. 'opacity': '0.5'
  775. }).css3({
  776. 'transform': 'scalex(0.0001)'
  777. });
  778. }, 50);
  779. }
  780. }, opts));
  781. }
  782. })(window.jQuery || window.Zepto);
  783. (function($) {
  784. flux.transitions.blinds3d = function(fluxslider, opts) {
  785. return new flux.transitions.tiles3d(fluxslider, $.extend({
  786. forceSquare: false,
  787. rows: 1,
  788. columns: 6
  789. }, opts));
  790. };
  791. })(window.jQuery || window.Zepto);
  792. (function($) {
  793. flux.transitions.zip = function(fluxslider, opts) {
  794. return new flux.transitions.bars(fluxslider, $.extend({
  795. execute: function() {
  796. var _this = this;
  797. var height = this.slider.image1.height();
  798. var bars = this.slider.image1.find('div.tile');
  799. // Get notified when the last transition has completed
  800. $(bars[bars.length-1]).transitionEnd(function(){
  801. _this.finished();
  802. });
  803. setTimeout(function(){
  804. bars.each(function(index, bar){
  805. $(bar).css({
  806. 'opacity': '0.3'
  807. }).css3({
  808. 'transform': flux.browser.translate(0, (index%2 ? '-'+(2*height) : height))
  809. });
  810. });
  811. }, 20);
  812. }
  813. }, opts));
  814. };
  815. })(window.jQuery || window.Zepto);
  816. (function($) {
  817. flux.transitions.blocks = function(fluxslider, opts) {
  818. return new flux.transition_grid(fluxslider, $.extend({
  819. forceSquare: true,
  820. delayBetweenBars: 100,
  821. renderTile: function(elem, colIndex, rowIndex, colWidth, rowHeight, leftOffset, topOffset) {
  822. var delay = Math.floor(Math.random()*10*this.options.delayBetweenBars);
  823. $(elem).css({
  824. 'background-image': this.slider.image1.css('background-image'),
  825. 'background-position': '-'+leftOffset+'px -'+topOffset+'px'
  826. }).css3({
  827. 'transition-duration': '350ms',
  828. 'transition-timing-function': 'ease-in',
  829. 'transition-property': 'all',
  830. 'transition-delay': delay+'ms'
  831. });
  832. // Keep track of the last elem to fire
  833. if(this.maxDelay === undefined)
  834. this.maxDelay = 0;
  835. if(delay > this.maxDelay)
  836. {
  837. this.maxDelay = delay;
  838. this.maxDelayTile = elem;
  839. }
  840. },
  841. execute: function() {
  842. var _this = this;
  843. var blocks = this.slider.image1.find('div.tile');
  844. // Get notified when the last transition has completed
  845. this.maxDelayTile.transitionEnd(function(){
  846. _this.finished();
  847. });
  848. setTimeout(function(){
  849. blocks.each(function(index, block){
  850. $(block).css({
  851. 'opacity': '0'
  852. }).css3({
  853. 'transform': 'scale(0.8)'
  854. });
  855. });
  856. }, 50);
  857. }
  858. }, opts));
  859. };
  860. })(window.jQuery || window.Zepto);
  861. (function($) {
  862. flux.transitions.blocks2 = function(fluxslider, opts) {
  863. return new flux.transition_grid(fluxslider, $.extend({
  864. cols: 12,
  865. forceSquare: true,
  866. delayBetweenDiagnols: 150,
  867. renderTile: function(elem, colIndex, rowIndex, colWidth, rowHeight, leftOffset, topOffset) {
  868. var delay = Math.floor(Math.random()*10*this.options.delayBetweenBars);
  869. $(elem).css({
  870. 'background-image': this.slider.image1.css('background-image'),
  871. 'background-position': '-'+leftOffset+'px -'+topOffset+'px'
  872. }).css3({
  873. 'transition-duration': '350ms',
  874. 'transition-timing-function': 'ease-in',
  875. 'transition-property': 'all',
  876. 'transition-delay': (colIndex+rowIndex)*this.options.delayBetweenDiagnols+'ms',
  877. 'backface-visibility': 'hidden' // trigger hardware acceleration
  878. });
  879. },
  880. execute: function() {
  881. var _this = this;
  882. var blocks = this.slider.image1.find('div.tile');
  883. // Get notified when the last transition has completed
  884. blocks.last().transitionEnd(function(){
  885. _this.finished();
  886. });
  887. setTimeout(function(){
  888. blocks.each(function(index, block){
  889. $(block).css({
  890. 'opacity': '0'
  891. }).css3({
  892. 'transform': 'scale(0.8)'
  893. });
  894. });
  895. }, 50);
  896. }
  897. }, opts));
  898. };
  899. })(window.jQuery || window.Zepto);
  900. (function($) {
  901. flux.transitions.concentric = function(fluxslider, opts) {
  902. return new flux.transition(fluxslider, $.extend({
  903. blockSize: 60,
  904. delay: 150,
  905. alternate: false,
  906. setup: function() {
  907. var w = this.slider.image1.width(),
  908. h = this.slider.image1.height(),
  909. largestLength = Math.sqrt(w*w + h*h), // Largest length is the diagonal
  910. // How many blocks do we need?
  911. blockCount = Math.ceil(((largestLength-this.options.blockSize)/2) / this.options.blockSize) + 1, // 1 extra to account for the round border
  912. fragment = document.createDocumentFragment();
  913. for(var i=0; i<blockCount; i++)
  914. {
  915. var thisBlockSize = (2*i*this.options.blockSize)+this.options.blockSize;
  916. var block = $('<div></div>').attr('class', 'block block-'+i).css({
  917. width: thisBlockSize+'px',
  918. height: thisBlockSize+'px',
  919. position: 'absolute',
  920. top: ((h-thisBlockSize)/2)+'px',
  921. left: ((w-thisBlockSize)/2)+'px',
  922. 'z-index': 100+(blockCount-i),
  923. 'background-image': this.slider.image1.css('background-image'),
  924. 'background-position': 'center center'
  925. }).css3({
  926. 'border-radius': thisBlockSize+'px',
  927. 'transition-duration': '800ms',
  928. 'transition-timing-function': 'linear',
  929. 'transition-property': 'all',
  930. 'transition-delay': ((blockCount-i)*this.options.delay)+'ms'
  931. });
  932. fragment.appendChild(block.get(0));
  933. }
  934. //this.slider.image1.append($(fragment));
  935. this.slider.image1.get(0).appendChild(fragment);
  936. },
  937. execute: function() {
  938. var _this = this;
  939. var blocks = this.slider.image1.find('div.block');
  940. // Get notified when the last transition has completed
  941. $(blocks[0]).transitionEnd(function(){
  942. _this.finished();
  943. });
  944. setTimeout(function(){
  945. blocks.each(function(index, block){
  946. $(block).css({
  947. 'opacity': '0'
  948. }).css3({
  949. 'transform': flux.browser.rotateZ((!_this.options.alternate || index%2 ? '' : '-')+'90')
  950. });
  951. });
  952. }, 50);
  953. }
  954. }, opts));
  955. };
  956. })(window.jQuery || window.Zepto);
  957. (function($) {
  958. flux.transitions.warp = function(fluxslider, opts) {
  959. return new flux.transitions.concentric(fluxslider, $.extend({
  960. delay: 30,
  961. alternate: true
  962. }, opts));
  963. };
  964. })(window.jQuery || window.Zepto);
  965. (function($) {
  966. flux.transitions.cube = function(fluxslider, opts) {
  967. return new flux.transition(fluxslider, $.extend({
  968. requires3d: true,
  969. barWidth: 100,
  970. direction: 'left',
  971. perspective: 1000,
  972. setup: function() {
  973. var width = this.slider.image1.width();
  974. var height = this.slider.image1.height();
  975. // Setup the container to allow 3D perspective
  976. this.slider.image1.css3({
  977. 'perspective': this.options.perspective,
  978. 'perspective-origin': '50% 50%'
  979. });
  980. this.cubeContainer = $('<div class="cube"></div>').css({
  981. width: width+'px',
  982. height: height+'px',
  983. position: 'relative'
  984. }).css3({
  985. 'transition-duration': '800ms',
  986. 'transition-timing-function': 'linear',
  987. 'transition-property': 'all',
  988. 'transform-style': 'preserve-3d'
  989. });
  990. var css = {
  991. height: '100%',
  992. width: '100%',
  993. position: 'absolute',
  994. top: '0px',
  995. left: '0px'
  996. };
  997. var currentFace = $('<div class="face current"></div>').css($.extend(css, {
  998. background: this.slider.image1.css('background-image')
  999. })).css3({
  1000. 'backface-visibility': 'hidden'
  1001. });
  1002. this.cubeContainer.append(currentFace);
  1003. var nextFace = $('<div class="face next"></div>').css($.extend(css, {
  1004. background: this.slider.image2.css('background-image')
  1005. })).css3({
  1006. 'transform' : this.options.transitionStrings.call(this, this.options.direction, 'nextFace'),
  1007. 'backface-visibility': 'hidden'
  1008. });
  1009. this.cubeContainer.append(nextFace);
  1010. this.slider.image1.append(this.cubeContainer);
  1011. },
  1012. execute: function() {
  1013. var _this = this;
  1014. var width = this.slider.image1.width();
  1015. var height = this.slider.image1.height();
  1016. this.slider.image2.hide();
  1017. this.cubeContainer.transitionEnd(function(){
  1018. _this.slider.image2.show();
  1019. _this.finished();
  1020. });
  1021. setTimeout(function(){
  1022. _this.cubeContainer.css3({
  1023. 'transform' : _this.options.transitionStrings.call(_this, _this.options.direction, 'container')
  1024. });
  1025. }, 50);
  1026. },
  1027. transitionStrings: function(direction, elem) {
  1028. var width = this.slider.image1.width();
  1029. var height = this.slider.image1.height();
  1030. // Define the various transforms that are required to perform various cube rotations
  1031. var t = {
  1032. 'up' : {
  1033. 'nextFace': flux.browser.rotateX(-90) + ' ' + flux.browser.translate(0, height/2, height/2),
  1034. 'container': flux.browser.rotateX(90) + ' ' + flux.browser.translate(0, -height/2, height/2)
  1035. },
  1036. 'down' : {
  1037. 'nextFace': flux.browser.rotateX(90) + ' ' + flux.browser.translate(0, -height/2, height/2),
  1038. 'container': flux.browser.rotateX(-90) + ' ' + flux.browser.translate(0, height/2, height/2)
  1039. },
  1040. 'left' : {
  1041. 'nextFace': flux.browser.rotateY(90) + ' ' + flux.browser.translate(width/2, 0, width/2),
  1042. 'container': flux.browser.rotateY(-90) + ' ' + flux.browser.translate(-width/2, 0, width/2)
  1043. },
  1044. 'right' : {
  1045. 'nextFace': flux.browser.rotateY(-90) + ' ' + flux.browser.translate(-width/2, 0, width/2),
  1046. 'container': flux.browser.rotateY(90) + ' ' + flux.browser.translate(width/2, 0, width/2)
  1047. }
  1048. };
  1049. return (t[direction] && t[direction][elem]) ? t[direction][elem] : false;
  1050. }
  1051. }, opts));
  1052. };
  1053. })(window.jQuery || window.Zepto);
  1054. (function($) {
  1055. flux.transitions.tiles3d = function(fluxslider, opts) {
  1056. return new flux.transition_grid(fluxslider, $.extend({
  1057. requires3d: true,
  1058. forceSquare: true,
  1059. columns: 5,
  1060. perspective: 600,
  1061. delayBetweenBarsX: 200,
  1062. delayBetweenBarsY: 150,
  1063. renderTile: function(elem, colIndex, rowIndex, colWidth, rowHeight, leftOffset, topOffset) {
  1064. var tile = $('<div></div>').css({
  1065. width: colWidth+'px',
  1066. height: rowHeight+'px',
  1067. position: 'absolute',
  1068. top: '0px',
  1069. left: '0px',
  1070. //'z-index': 200, // Removed to make compatible with FF10 (Chrome bug seems to have been fixed)
  1071. 'background-image': this.slider.image1.css('background-image'),
  1072. 'background-position': '-'+leftOffset+'px -'+topOffset+'px',
  1073. 'background-repeat': 'no-repeat',
  1074. '-moz-transform': 'translateZ(1px)'
  1075. }).css3({
  1076. 'backface-visibility': 'hidden'
  1077. });
  1078. var tile2 = $(tile.get(0).cloneNode(false)).css({
  1079. 'background-image': this.slider.image2.css('background-image')
  1080. //'z-index': 190 // Removed to make compatible with FF10 (Chrome bug seems to have been fixed)
  1081. }).css3({
  1082. 'transform': flux.browser.rotateY(180),
  1083. 'backface-visibility': 'hidden'
  1084. });
  1085. $(elem).css({
  1086. 'z-index': (colIndex > this.options.columns/2 ? 500-colIndex : 500) + (rowIndex > this.options.rows/2 ? 500-rowIndex : 500) // Fix for Chrome to ensure that the z-index layering is correct!
  1087. }).css3({
  1088. 'transition-duration': '800ms',
  1089. 'transition-timing-function': 'ease-out',
  1090. 'transition-property': 'all',
  1091. 'transition-delay': (colIndex*this.options.delayBetweenBarsX+rowIndex*this.options.delayBetweenBarsY)+'ms',
  1092. 'transform-style': 'preserve-3d'
  1093. }).append(tile).append(tile2);
  1094. },
  1095. execute: function() {
  1096. this.slider.image1.css3({
  1097. 'perspective': this.options.perspective,
  1098. 'perspective-origin': '50% 50%'
  1099. });
  1100. var _this = this;
  1101. var tiles = this.slider.image1.find('div.tile');
  1102. this.slider.image2.hide();
  1103. // Get notified when the last transition has completed
  1104. tiles.last().transitionEnd(function(event){
  1105. _this.slider.image2.show();
  1106. _this.finished();
  1107. });
  1108. setTimeout(function(){
  1109. tiles.css3({
  1110. 'transform': flux.browser.rotateY(180)
  1111. });
  1112. }, 50);
  1113. }
  1114. }, opts));
  1115. };
  1116. })(window.jQuery || window.Zepto);
  1117. (function($) {
  1118. flux.transitions.turn = function(fluxslider, opts) {
  1119. return new flux.transition(fluxslider, $.extend({
  1120. requires3d: true,
  1121. perspective: 1300,
  1122. direction: 'left',
  1123. setup: function() {
  1124. var tab = $('<div class="tab"></div>').css({
  1125. width: '50%',
  1126. height: '100%',
  1127. position: 'absolute',
  1128. top: '0px',
  1129. left: this.options.direction == 'left' ? '50%' : '0%',
  1130. 'z-index':101
  1131. }).css3({
  1132. 'transform-style': 'preserve-3d',
  1133. 'transition-duration': '1000ms',
  1134. 'transition-timing-function': 'ease-out',
  1135. 'transition-property': 'all',
  1136. 'transform-origin': this.options.direction == 'left' ? 'left center' : 'right center'
  1137. }),
  1138. front = $('<div></div>').appendTo(tab).css({
  1139. 'background-image': this.slider.image1.css('background-image'),
  1140. 'background-position': (this.options.direction == 'left' ? '-'+(this.slider.image1.width()/2) : 0)+'px 0',
  1141. width: '100%',
  1142. height: '100%',
  1143. position: 'absolute',
  1144. top: '0',
  1145. left: '0',
  1146. '-moz-transform': 'translateZ(1px)'
  1147. }).css3({
  1148. 'backface-visibility': 'hidden'
  1149. }),
  1150. back = $('<div></div>').appendTo(tab).css({
  1151. 'background-image': this.slider.image2.css('background-image'),
  1152. 'background-position': (this.options.direction == 'left' ? 0 : '-'+(this.slider.image1.width()/2))+'px 0',
  1153. width: '100%',
  1154. height: '100%',
  1155. position: 'absolute',
  1156. top: '0',
  1157. left: '0'
  1158. }).css3({
  1159. transform: flux.browser.rotateY(180),
  1160. 'backface-visibility': 'hidden'
  1161. }),
  1162. current = $('<div></div>').css({
  1163. position: 'absolute',
  1164. top: '0',
  1165. left: this.options.direction == 'left' ? '0' : '50%',
  1166. width: '50%',
  1167. height: '100%',
  1168. 'background-image': this.slider.image1.css('background-image'),
  1169. 'background-position': (this.options.direction == 'left' ? 0 : '-'+(this.slider.image1.width()/2))+'px 0',
  1170. 'z-index':100
  1171. }),
  1172. overlay = $('<div class="overlay"></div>').css({
  1173. position: 'absolute',
  1174. top: '0',
  1175. left: this.options.direction == 'left' ? '50%' : '0',
  1176. width: '50%',
  1177. height: '100%',
  1178. background: '#000',
  1179. opacity: 1
  1180. }).css3({
  1181. 'transition-duration': '800ms',
  1182. 'transition-timing-function': 'linear',
  1183. 'transition-property': 'opacity'
  1184. }),
  1185. container = $('<div></div>').css3({
  1186. width: '100%',
  1187. height: '100%'
  1188. }).css3({
  1189. 'perspective': this.options.perspective,
  1190. 'perspective-origin': '50% 50%'
  1191. }).append(tab).append(current).append(overlay);
  1192. this.slider.image1.append(container);
  1193. },
  1194. execute: function() {
  1195. var _this = this;
  1196. this.slider.image1.find('div.tab').first().transitionEnd(function(){
  1197. _this.finished();
  1198. });
  1199. setTimeout(function(){
  1200. _this.slider.image1.find('div.tab').css3({
  1201. // 179 not 180 so that the tab rotates the correct way in Firefox
  1202. transform: flux.browser.rotateY(_this.options.direction == 'left' ? -179 : 179)
  1203. });
  1204. _this.slider.image1.find('div.overlay').css({
  1205. opacity: 0
  1206. });
  1207. }, 50);
  1208. }
  1209. }, opts));
  1210. };
  1211. })(window.jQuery || window.Zepto);
  1212. (function($) {
  1213. flux.transitions.slide = function(fluxslider, opts) {
  1214. return new flux.transition(fluxslider, $.extend({
  1215. direction: 'left',
  1216. setup: function() {
  1217. var width = this.slider.image1.width(),
  1218. height = this.slider.image1.height(),
  1219. currentImage = $('<div class="current"></div>').css({
  1220. height: height+'px',
  1221. width: width+'px',
  1222. position: 'absolute',
  1223. top: '0px',
  1224. left: '0px',
  1225. background: this.slider[this.options.direction == 'left' ? 'image1' : 'image2'].css('background-image')
  1226. }).css3({
  1227. 'backface-visibility': 'hidden'
  1228. }),
  1229. nextImage = $('<div class="next"></div>').css({
  1230. height: height+'px',
  1231. width: width+'px',
  1232. position: 'absolute',
  1233. top: '0px',
  1234. left: width+'px',
  1235. background: this.slider[this.options.direction == 'left' ? 'image2' : 'image1'].css('background-image')
  1236. }).css3({
  1237. 'backface-visibility': 'hidden'
  1238. });
  1239. this.slideContainer = $('<div class="slide"></div>').css({
  1240. width: (2*width)+'px',
  1241. height: height+'px',
  1242. position: 'relative',
  1243. left: this.options.direction == 'left' ? '0px' : -width+'px',
  1244. 'z-index': 101
  1245. }).css3({
  1246. 'transition-duration': '600ms',
  1247. 'transition-timing-function': 'ease-in',
  1248. 'transition-property': 'all'
  1249. });
  1250. this.slideContainer.append(currentImage).append(nextImage);
  1251. this.slider.image1.append(this.slideContainer);
  1252. },
  1253. execute: function() {
  1254. var _this = this,
  1255. delta = this.slider.image1.width();
  1256. if(this.options.direction == 'left')
  1257. delta = -delta;
  1258. this.slideContainer.transitionEnd(function(){
  1259. _this.finished();
  1260. });
  1261. setTimeout(function(){
  1262. _this.slideContainer.css3({
  1263. 'transform' : flux.browser.translate(delta)
  1264. });
  1265. }, 50);
  1266. }
  1267. }, opts));
  1268. };
  1269. })(window.jQuery || window.Zepto);
  1270. (function($) {
  1271. flux.transitions.swipe = function(fluxslider, opts) {
  1272. return new flux.transition(fluxslider, $.extend({
  1273. setup: function() {
  1274. var img = $('<div></div>').css({
  1275. width: '100%',
  1276. height: '100%',
  1277. 'background-image': this.slider.image1.css('background-image')
  1278. }).css3({
  1279. 'transition-duration': '1600ms',
  1280. 'transition-timing-function': 'ease-in',
  1281. 'transition-property': 'all',
  1282. 'mask-image': '-webkit-linear-gradient(left, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 48%, rgba(0,0,0,1) 52%, rgba(0,0,0,1) 100%)',
  1283. 'mask-position': '70%',
  1284. 'mask-size': '400%'
  1285. });
  1286. this.slider.image1.append(img);
  1287. },
  1288. execute: function() {
  1289. //return;
  1290. var _this = this,
  1291. img = this.slider.image1.find('div');
  1292. // Get notified when the last transition has completed
  1293. $(img).transitionEnd(function(){
  1294. _this.finished();
  1295. });
  1296. setTimeout(function(){
  1297. $(img).css3({
  1298. 'mask-position': '30%'
  1299. });
  1300. }, 50);
  1301. },
  1302. compatibilityCheck: function() {
  1303. return flux.browser.supportsCSSProperty('MaskImage');
  1304. }
  1305. }, opts));
  1306. };
  1307. })(window.jQuery || window.Zepto);
  1308. (function($) {
  1309. flux.transitions.dissolve = function(fluxslider, opts) {
  1310. return new flux.transition(fluxslider, $.extend({
  1311. setup: function() {
  1312. var img = $('<div class="image"></div>').css({
  1313. width: '100%',
  1314. height: '100%',
  1315. 'background-image': this.slider.image1.css('background-image')
  1316. }).css3({
  1317. 'transition-duration': '600ms',
  1318. 'transition-timing-function': 'ease-in',
  1319. 'transition-property': 'opacity'
  1320. });
  1321. this.slider.image1.append(img);
  1322. },
  1323. execute: function() {
  1324. var _this = this,
  1325. img = this.slider.image1.find('div.image');
  1326. // Get notified when the last transition has completed
  1327. $(img).transitionEnd(function(){
  1328. _this.finished();
  1329. });
  1330. setTimeout(function(){
  1331. $(img).css({
  1332. 'opacity': '0.0'
  1333. });
  1334. }, 50);
  1335. }
  1336. }, opts));
  1337. };
  1338. })(window.jQuery || window.Zepto);