// dxee animation var dxee = dxee || {}; (function (){ function Slide (option) { // 슬ë¼ì´ë“œ í¬ì§€ì…˜ var pos = 0 // ìžë™ 실행 if (option.autoPlay) timer = setTimeout(play(option.type), option.setTime) // 슬ë¼ì´ë“œ 실행 function play (type) { // 함수 형태로 반환하여 setTimeoutì—ì„œ 실행ë 수 있ë„ë¡ í•¨ return { // 오른쪽ì—ì„œ 왼쪽으로 진행하는 슬ë¼ì´ë“œ rightToLeft: function () { // 슬ë¼ì´ë“œ ì„ íƒ if (++pos > option.len) pos = 0 else if (pos < 0) pos = option.len - 1 // ì´ì „ 슬ë¼ì´ë“œ 비활성, 현재 슬ë¼ì´ë“œ 활성 var before = option.wrap.find('.active').removeClass('active') // 슬ë¼ì´ë“œ 실행 function realPlay () { option.wrap.stop().animate({ marginLeft: -pos * 100 + '%' }, option.playTime, function () { // 마지막 장면ì—ì„œ 첫번째 장면으로 if (pos === option.len) { $(this).css({marginLeft: 0}) pos = 0 } var after = option.wrap.find('>*').eq(pos).addClass('active') // ì• ë‹ˆë©”ì´ì…˜ì´ 있다면, 실행 if (dxee.Animation) { dxee.Animation({obj: after }) } // ì¼ì • 시간 후 ìžë™ 실행 if (option.autoPlay) { timer = setTimeout(play(type), option.setTime) } }) } // ì• ë‹ˆë©”ì´ì…˜ì´ 있다면, 실행 if (dxee.Animation) { dxee.Animation({obj: before, reverse: true, callback: realPlay }) } else { realPlay() } } }[type] } } // 슬ë¼ì´ë“œ 세팅 Slide.init = function (obj) { $('.dxee-slide').each(function () { // option ì„¤ì • var target = $(this) var option = { autoPlay: target.data('autoPlay') || true, // ìžë™ì‹¤í–‰ 여부 playTime: target.data('playTime') || 1000, // 슬ë¼ì´ë“œ 실행 시간 setTime: target.data('setTime') || 5000, // ì „í™˜ 시간 type: target.data('type') || 'rightToLeft', // 슬ë¼ì´ë“œ 타입 wrap: target.find('.slide-wrap'), // ì´ë™í•˜ëŠ” ëŒ€ìƒ len: target.find('.slide-wrap>*').length // 슬ë¼ì´ë“œ 갯수 } // 첫번째 슬ë¼ì´ë“œ 활성화 target.find('.slide-wrap>*:first-child').addClass('active') // 슬ë¼ì´ë“œ 타입별 요소 사ì´ì¦ˆ ì§€ì • switch (option.type) { case 'rightToLeft' : option.wrap.css({ display: 'flex', width: (option.len + 1) * 100 + '%', height: '100%' }) .find('>*').css({ width: 100 / (option.len + 1) + '%', height: '100%' }) option.wrap.find('>*:first-child').clone().appendTo(option.wrap) break; } var timer = null new Slide(option) }) } dxee.Slide = Slide }());