|
|
|
|
/*
|
|
|
|
|
Demo:
|
|
|
|
|
$(".productshow").Xslider({
|
|
|
|
|
unitDisplayed: 1,//<2F><><EFBFBD>ӵĵ<D3B5>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
|
|
|
numtoMove: 1,
|
|
|
|
|
dir: "H",//ˮƽ<CBAE>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>Ǵ<EFBFBD>ֱ<EFBFBD>ƶ<EFBFBD> Ĭ<><C4AC>HΪˮƽ<CBAE>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ֱ<EFBFBD>ƶ<EFBFBD>,<2C><><EFBFBD><EFBFBD>F<EFBFBD><46><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>ע<EFBFBD><D7A2><EFBFBD>Ǵ<EFBFBD>д<EFBFBD><D0B4>ĸ,Fʱ<46><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>;
|
|
|
|
|
viewedSize:120,//<2F><><EFBFBD>ӿ<EFBFBD><D3BF>Ȼ<EFBFBD><C8BB>߶<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>߶<EFBFBD>;
|
|
|
|
|
unitLen:20,//<2F>ƶ<EFBFBD><C6B6>ĵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>߶ȣ<DFB6><C8A3><EFBFBD><EFBFBD>أ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>һ<EFBFBD><D2BB>li<6C>ijߴ<C4B3>;
|
|
|
|
|
speed: 500,//<2F><><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD>룩 Ĭ<><C4AC>Ϊ500;
|
|
|
|
|
autoScroll:2000,//<2F>Զ<EFBFBD><D4B6>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨<EFBFBD><E4A3A8><EFBFBD>룩 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2B2BBBB>Զ<EFBFBD><D4B6>ƶ<EFBFBD>;
|
|
|
|
|
loop:"cycle",//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
scrollObj:"ul",//Ҫ<>ƶ<EFBFBD><C6B6>Ķ<EFBFBD><C4B6><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>productshow<6F>µ<EFBFBD>ul;
|
|
|
|
|
scrollObjSize://<2F>ƶ<EFBFBD><C6B6><EFBFBD><EEB3A4><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD>Ҫ<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>Ȼ<EFBFBD><C8BB>߶ȣ<DFB6> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>li<6C><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>unitLen<65><6E><EFBFBD><EFBFBD>;
|
|
|
|
|
scrollunits: "li",//<2F>ƶ<EFBFBD><C6B6><EFBFBD>λ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬Ĭ<E9A3AC>ϵ<EFBFBD><CFB5>Dz<EFBFBD><C7B2><EFBFBD>li
|
|
|
|
|
curStyle: "current",//<2F><>ǰ<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>"current"
|
|
|
|
|
eventType: "click",//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
imgInit: 1,//<2F><>ǰ<EFBFBD><C7B0>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
stepOne: false,//<2F>ƶ<EFBFBD><C6B6><EFBFBD>ÿһ<C3BF><D2BB><EFBFBD>ƶ<EFBFBD><C6B6>㡣Ĭ<E3A1A3><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ
|
|
|
|
|
btnNext: "a.aright",//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD> Ĭ<><C4AC>Ϊ"a.aright"
|
|
|
|
|
btnPrevious: "a.aleft",//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD> Ĭ<><C4AC>Ϊ"a.aleft"
|
|
|
|
|
start:1,//<2F><><EFBFBD>ÿ<EFBFBD>ʼλ<CABC><CEBB> Ĭ<><C4AC><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<CABC>á<EFBFBD>
|
|
|
|
|
beforeStart:function(e){//<2F>ƶ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
//before code;
|
|
|
|
|
//e:{
|
|
|
|
|
goIndex: <EFBFBD><EFBFBD>ǰ<EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
container: slider<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
current: <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>λ,
|
|
|
|
|
next: <EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ,
|
|
|
|
|
eventTrigger: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
EOF: <EFBFBD>Ƿ<EFBFBD><EFBFBD>ǽ<EFBFBD>β,
|
|
|
|
|
BOF: <EFBFBD>Ƿ<EFBFBD><EFBFBD>ǿ<EFBFBD>ʼ
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
afterEnd:function(e){//<2F>ƶ<EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
//end code;
|
|
|
|
|
//e ͬ<><CDAC>
|
|
|
|
|
},
|
|
|
|
|
disableStyle: { previous: "agrayleft", next: "agrayright" },//<2F><><EFBFBD><EFBFBD>ʧЧʱ<D0A7><CAB1><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
|
|
|
|
|
navCurStyle: "current",//<2F><>ǰnav<61><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ Ĭ<><C4AC><EFBFBD><EFBFBD>"current"
|
|
|
|
|
showNav: null,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫnav<61><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD> Ĭ<><C4AC>Ϊnull
|
|
|
|
|
navEventType: "mouseenter"//nav<61><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD> Ĭ<><C4AC>Ϊclick
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
<EFBFBD>¼<EFBFBD>
|
|
|
|
|
go: function (n, eventTrigger, callback);//<2F>ƶ<EFBFBD><C6B6><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{n:<3A>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,eventTrigger:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<C9BA><F3B4A5B7><EFBFBD><EFBFBD>¼<EFBFBD>}
|
|
|
|
|
prev: function ();//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>λ
|
|
|
|
|
next: function ();//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>λ
|
|
|
|
|
getSet: function ();//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
init: function (settings);//<2F><><EFBFBD>³<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> settings<67><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
getThis: function ();//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
eq: function (n);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊһ<CEAA><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>n<EFBFBD><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
|
$.extend($.easing, {
|
|
|
|
|
easeOutQuint: function(x, t, b, c, d) {
|
|
|
|
|
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var init = function(container, settings) {
|
|
|
|
|
var self = this;
|
|
|
|
|
self.settings = settings;
|
|
|
|
|
self.container = container;
|
|
|
|
|
self.selector = container.selector;
|
|
|
|
|
self.container.each(function() {
|
|
|
|
|
var me = $(this);
|
|
|
|
|
var scrollObj = me.find(settings.scrollObj),
|
|
|
|
|
scrollunits = scrollObj.find(settings.scrollunits),
|
|
|
|
|
unitLen = settings.unitLen || (settings.dir == "H" ? scrollunits.eq(0).outerWidth() : scrollunits.eq(0).outerHeight()),
|
|
|
|
|
unitDisplayed = settings.unitDisplayed,
|
|
|
|
|
numtoMove = settings.numtoMove > unitDisplayed ? unitDisplayed : settings.numtoMove;
|
|
|
|
|
scrollObj.parent().css({ position: "relative", overflow: "hidden" });
|
|
|
|
|
var runenv = {
|
|
|
|
|
scrollObj: scrollObj,
|
|
|
|
|
viewedSize: settings.viewedSize || (settings.dir == "H" ? scrollObj.parent().width() : scrollObj.parent().height()), //length of the wrapper visible;
|
|
|
|
|
scrollunits: scrollunits, //units to move;
|
|
|
|
|
unitLen: unitLen,
|
|
|
|
|
unitDisplayed: unitDisplayed, //units num displayed;
|
|
|
|
|
numtoMove: settings.numtoMove > unitDisplayed ? unitDisplayed : settings.numtoMove,
|
|
|
|
|
scrollObjSize: settings.scrollObjSize || scrollunits.length * unitLen, //length of the scrollObj;
|
|
|
|
|
offset: 0, //max width to move;
|
|
|
|
|
offsetnow: 0, //scrollObj now offset;
|
|
|
|
|
movelength: unitLen * numtoMove,
|
|
|
|
|
pos: settings.dir == "H" ? "left" : "top",
|
|
|
|
|
moving: false, //moving now?;
|
|
|
|
|
start: settings.start,
|
|
|
|
|
btnright: me.find(settings.btnNext),
|
|
|
|
|
btnleft: me.find(settings.btnPrevious)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((runenv.viewedSize / runenv.unitLen) > runenv.scrollunits.length) {
|
|
|
|
|
settings.loop = "";
|
|
|
|
|
}
|
|
|
|
|
runenv.scrollObjSize = Math.max(runenv.scrollObjSize, runenv.viewedSize);
|
|
|
|
|
|
|
|
|
|
if (settings.loop == "cycle") {
|
|
|
|
|
runenv.canMoveLength = runenv.scrollunits.length;
|
|
|
|
|
} else if (settings.stepOne) {
|
|
|
|
|
runenv.canMoveLength = runenv.scrollunits.length;
|
|
|
|
|
runenv.canMoveSize = runenv.scrollObjSize - runenv.viewedSize;
|
|
|
|
|
} else {
|
|
|
|
|
runenv.canMoveSize = runenv.scrollObjSize - runenv.viewedSize;
|
|
|
|
|
runenv.canMoveLength = Math.ceil(runenv.canMoveSize / runenv.unitLen) + 1;
|
|
|
|
|
}
|
|
|
|
|
runenv.scrollunits.each(function(k, i) {
|
|
|
|
|
$(this).attr("index", k);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
//initialization css
|
|
|
|
|
|
|
|
|
|
if (settings.dir == "F2") {
|
|
|
|
|
var len = runenv.scrollunits.length;
|
|
|
|
|
runenv.scrollunits.each(function(i, v) {
|
|
|
|
|
$(this).css("z-index", len - i);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
settings.dir == "H" ? runenv.scrollObj.css("left", "0px") : runenv.scrollObj.css("top", "0px");
|
|
|
|
|
|
|
|
|
|
//cycle tyle initialization dom
|
|
|
|
|
if (settings.loop == "cycle") {
|
|
|
|
|
var frontobj = [], backobj = [];
|
|
|
|
|
for (var i = 0; i < runenv.unitDisplayed; i++) {
|
|
|
|
|
var beforeobj = runenv.scrollunits.eq(runenv.scrollunits.length - runenv.unitDisplayed + i).clone();
|
|
|
|
|
var afterobj = runenv.scrollunits.eq(runenv.unitDisplayed - i - 1).clone();
|
|
|
|
|
beforeobj.attr("index", ~ ~beforeobj.attr("index") - runenv.unitDisplayed - 1);
|
|
|
|
|
afterobj.attr("index", ~ ~afterobj.attr("index") + runenv.unitDisplayed + 1);
|
|
|
|
|
runenv.scrollunits.eq(0).before(beforeobj);
|
|
|
|
|
runenv.scrollunits.eq(runenv.scrollunits.length - 1).after(afterobj);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var offset_c = 0 - runenv.unitLen * (runenv.unitDisplayed - runenv.start + 1);
|
|
|
|
|
settings.dir == "H" ? runenv.scrollObj.css("left", offset_c) : runenv.scrollObj.css("top", offset_c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//save environment variable
|
|
|
|
|
var current = scrollunits.eq(0);
|
|
|
|
|
me.data("runenv", runenv);
|
|
|
|
|
me.data("curobj", current);
|
|
|
|
|
me.data("curindex", 1);
|
|
|
|
|
self.settings.canMoveSize = runenv.canMoveSize;
|
|
|
|
|
self.settings.canMoveLength = runenv.canMoveLength;
|
|
|
|
|
|
|
|
|
|
//setting current
|
|
|
|
|
runenv.scrollunits.removeClass(settings.curStyle);
|
|
|
|
|
runenv.scrollunits.eq(settings.imgInit - 1).addClass(settings.curStyle);
|
|
|
|
|
|
|
|
|
|
//move to starting position
|
|
|
|
|
fnmove.call(me, me.current, settings.imgInit, settings, true);
|
|
|
|
|
if (settings.showNav) {
|
|
|
|
|
if (typeof settings.showNav === 'boolean') {
|
|
|
|
|
settings.showNav = ".nav";
|
|
|
|
|
}
|
|
|
|
|
me.find(settings.showNav).removeClass(settings.navCurStyle);
|
|
|
|
|
me.find(settings.showNav).eq(settings.imgInit - 1).addClass(settings.navCurStyle);
|
|
|
|
|
me.find(settings.showNav).bind(settings.navEventType, function(e) {
|
|
|
|
|
fnmove.call(me, current, $(this).index() + 1, settings);
|
|
|
|
|
//return false;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var init3D = function(container, settings) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var fnmove = function(cur, goIndex, settings, flg, eventTrigger, callback) {
|
|
|
|
|
var self = $(this), offset_0 = 0, gotoIndex = goIndex;
|
|
|
|
|
var curindex = self.data("curindex");
|
|
|
|
|
|
|
|
|
|
var runenv = self.data("runenv");
|
|
|
|
|
if (settings.loop == "cycle") {
|
|
|
|
|
|
|
|
|
|
if (goIndex <= 0) {
|
|
|
|
|
offset_0 = (curindex + runenv.scrollunits.length + runenv.unitDisplayed - runenv.start) * runenv.unitLen;
|
|
|
|
|
|
|
|
|
|
settings.dir == "H" ? runenv.scrollObj.css("left", -offset_0) : runenv.scrollObj.css("top", -offset_0);
|
|
|
|
|
goIndex = runenv.scrollunits.length + goIndex;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (curindex > runenv.scrollunits.length - runenv.unitDisplayed && goIndex > runenv.scrollunits.length) {
|
|
|
|
|
offset_0 = (curindex - runenv.scrollunits.length + runenv.unitDisplayed - runenv.start) * runenv.unitLen;
|
|
|
|
|
settings.dir == "H" ? runenv.scrollObj.css("left", -offset_0) : runenv.scrollObj.css("top", -offset_0);
|
|
|
|
|
goIndex = ((goIndex - 1) % runenv.scrollunits.length) + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goIndex = goIndex >= runenv.canMoveLength ? runenv.canMoveLength : goIndex;
|
|
|
|
|
|
|
|
|
|
if (goIndex <= 0) {
|
|
|
|
|
goIndex = 1;
|
|
|
|
|
}
|
|
|
|
|
if (goIndex > 0) {
|
|
|
|
|
var offset = runenv.unitLen * (goIndex - runenv.start);
|
|
|
|
|
if (offset < 0) offset = 0;
|
|
|
|
|
self.data("curindex", goIndex);
|
|
|
|
|
var currentobj = self.data("curobj");
|
|
|
|
|
var EOF = false;
|
|
|
|
|
var BOF = false;
|
|
|
|
|
self.data("curobj", runenv.scrollunits.eq(goIndex - 1));
|
|
|
|
|
runenv.scrollunits.removeClass(settings.curStyle);
|
|
|
|
|
runenv.scrollunits.eq(goIndex - 1).addClass(settings.curStyle);
|
|
|
|
|
if (settings.showNav) {
|
|
|
|
|
self.find(settings.showNav).removeClass(settings.navCurStyle);
|
|
|
|
|
self.find(settings.showNav).eq(goIndex - 1).addClass(settings.navCurStyle);
|
|
|
|
|
}
|
|
|
|
|
if (settings.loop == "cycle") {
|
|
|
|
|
offset = runenv.unitLen * (goIndex - runenv.start + runenv.unitDisplayed);
|
|
|
|
|
}
|
|
|
|
|
if (curindex > goIndex) {
|
|
|
|
|
if (settings.loop == "cycle") {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
offset = offset <= runenv.scrollObjSize - runenv.viewedSize ? offset : runenv.scrollObjSize - runenv.viewedSize;
|
|
|
|
|
}
|
|
|
|
|
//console.log("<-", runenv.scrollObjSize - runenv.viewedSize - runenv.unitLen, offset);
|
|
|
|
|
if (offset <= runenv.scrollObjSize - runenv.viewedSize || settings.loop == "cycle") {
|
|
|
|
|
if (goIndex <= 1 && settings.loop != "cycle") {
|
|
|
|
|
BOF = true;
|
|
|
|
|
}
|
|
|
|
|
settings.beforeStart.call(self, {
|
|
|
|
|
goIndex: gotoIndex,
|
|
|
|
|
container: self,
|
|
|
|
|
current: currentobj,
|
|
|
|
|
next: runenv.scrollunits.eq(goIndex - 1),
|
|
|
|
|
eventTrigger: eventTrigger,
|
|
|
|
|
EOF: EOF,
|
|
|
|
|
BOF: BOF
|
|
|
|
|
});
|
|
|
|
|
$.fn.Xslider.sn.animate.call(self, runenv.scrollObj, -offset, settings.dir, runenv.unitLen, settings.speed, function() {
|
|
|
|
|
|
|
|
|
|
settings.afterEnd.call(self, {
|
|
|
|
|
goIndex: gotoIndex,
|
|
|
|
|
container: self,
|
|
|
|
|
current: currentobj,
|
|
|
|
|
next: runenv.scrollunits.eq(goIndex - 1),
|
|
|
|
|
eventTrigger: eventTrigger,
|
|
|
|
|
EOF: EOF,
|
|
|
|
|
BOF: BOF
|
|
|
|
|
});
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback.call(self);
|
|
|
|
|
}
|
|
|
|
|
}, flg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (curindex == goIndex) {
|
|
|
|
|
//console.log("==");
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback.call(self);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//console.log("->");
|
|
|
|
|
|
|
|
|
|
if (settings.loop == "cycle") {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
runenv.scrollObjSize = runenv.scrollObjSize < runenv.viewedSize ? runenv.viewedSize : runenv.scrollObjSize;
|
|
|
|
|
offset = runenv.viewedSize > runenv.scrollObjSize - offset ? runenv.scrollObjSize - runenv.viewedSize : offset;
|
|
|
|
|
}
|
|
|
|
|
if (goIndex >= runenv.canMoveLength && settings.loop != "cycle") {
|
|
|
|
|
EOF = true;
|
|
|
|
|
}
|
|
|
|
|
settings.beforeStart.call(self, {
|
|
|
|
|
goIndex: gotoIndex,
|
|
|
|
|
container: self,
|
|
|
|
|
current: currentobj,
|
|
|
|
|
next: runenv.scrollunits.eq(goIndex - 1),
|
|
|
|
|
eventTrigger: eventTrigger,
|
|
|
|
|
EOF: EOF,
|
|
|
|
|
BOF: BOF
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$.fn.Xslider.sn.animate.call(self, runenv.scrollObj, -offset, settings.dir, runenv.unitLen, settings.speed, function() {
|
|
|
|
|
settings.afterEnd.call(self, {
|
|
|
|
|
goIndex: gotoIndex,
|
|
|
|
|
container: self,
|
|
|
|
|
current: currentobj,
|
|
|
|
|
next: runenv.scrollunits.eq(goIndex - 1),
|
|
|
|
|
eventTrigger: eventTrigger,
|
|
|
|
|
EOF: EOF,
|
|
|
|
|
BOF: BOF
|
|
|
|
|
});
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback.call(self);
|
|
|
|
|
}
|
|
|
|
|
}, flg);
|
|
|
|
|
}
|
|
|
|
|
runenv.btnleft.removeClass(settings.disableStyle.previous);
|
|
|
|
|
runenv.btnright.removeClass(settings.disableStyle.next);
|
|
|
|
|
|
|
|
|
|
if (goIndex <= 1 && settings.loop != "cycle") {
|
|
|
|
|
runenv.btnleft.addClass(settings.disableStyle.previous);
|
|
|
|
|
}
|
|
|
|
|
if (goIndex >= runenv.canMoveLength && settings.loop != "cycle") {
|
|
|
|
|
runenv.btnright.addClass(settings.disableStyle.next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (settings.loop != "cycle") {
|
|
|
|
|
runenv.btnleft.addClass(settings.disableStyle.previous);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var fnmuve3D = function(cur, goIndex, settings, flg, eventTrigger, callback) {
|
|
|
|
|
var self = $(this), offset_0 = 0, gotoIndex = goIndex;
|
|
|
|
|
var curindex = self.data("curindex");
|
|
|
|
|
|
|
|
|
|
var runenv = self.data("runenv");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var nextEvent = function(settings, eventTrigger) {
|
|
|
|
|
var me = this;
|
|
|
|
|
fnmove.call(me, me.data("curobj"), me.data("curindex") + settings.numtoMove, settings, false, eventTrigger);
|
|
|
|
|
}
|
|
|
|
|
var previousEvent = function(settings, eventTrigger) {
|
|
|
|
|
var me = this;
|
|
|
|
|
fnmove.call(me, me.data("curobj"), me.data("curindex") - settings.numtoMove, settings, false, eventTrigger);
|
|
|
|
|
}
|
|
|
|
|
var ClassSlider = function(container, settings) {
|
|
|
|
|
var self = this;
|
|
|
|
|
// factory or constructor
|
|
|
|
|
if (!(self instanceof ClassSlider)) {
|
|
|
|
|
return new ClassSlider(container, $.extend({}, $.fn.Xslider.sn.defaults, settings));
|
|
|
|
|
}
|
|
|
|
|
self.settings = settings;
|
|
|
|
|
init.call(this, container, self.settings);
|
|
|
|
|
|
|
|
|
|
self.container.each(function() {
|
|
|
|
|
var me = $(this);
|
|
|
|
|
var runenv = $(this).data("runenv");
|
|
|
|
|
var btnright = $(this).find(settings.btnNext),
|
|
|
|
|
btnleft = $(this).find(settings.btnPrevious);
|
|
|
|
|
btnleft.unbind(settings.eventType).bind(settings.eventType, function() {
|
|
|
|
|
previousEvent.call(me, settings, this);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
btnright.unbind(settings.eventType).bind(settings.eventType, function() {
|
|
|
|
|
nextEvent.call(me, settings, this);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (settings.autoScroll && runenv.scrollunits.length > runenv.unitDisplayed) {
|
|
|
|
|
//$.fn.Xslider.sn.autoScroll.call(self,me, settings.autoScroll);
|
|
|
|
|
var autoScrolling = function() {
|
|
|
|
|
if (runenv.scrollunits.length <= ~ ~me.data("curindex") && settings.loop != "cycle") {
|
|
|
|
|
fnmove.call(me, me.data("curobj"), 1, settings);
|
|
|
|
|
} else {
|
|
|
|
|
nextEvent.call(me, settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var scrollTimmer = setInterval(autoScrolling, settings.autoScroll);
|
|
|
|
|
|
|
|
|
|
me.hover(function() {
|
|
|
|
|
clearInterval(scrollTimmer);
|
|
|
|
|
}, function() {
|
|
|
|
|
clearInterval(scrollTimmer);
|
|
|
|
|
scrollTimmer = setInterval(autoScrolling, settings.autoScroll);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
ClassSlider.prototype = {
|
|
|
|
|
go: function(n, eventTrigger, callback) {
|
|
|
|
|
var self = this;
|
|
|
|
|
//self.container = $(self.selector);
|
|
|
|
|
self.container.each(function() {
|
|
|
|
|
var me = $(this);
|
|
|
|
|
fnmove.call(me, me.data("curobj"), n, self.settings, false, eventTrigger, callback);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
prev: function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
self.container.each(function() {
|
|
|
|
|
var me = $(this);
|
|
|
|
|
previousEvent.call(me, self.settings);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
next: function() {
|
|
|
|
|
var self = this;
|
|
|
|
|
self.container.each(function() {
|
|
|
|
|
var me = $(this);
|
|
|
|
|
nextEvent.call(me, self.settings);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getSet: function() {
|
|
|
|
|
return this.settings;
|
|
|
|
|
},
|
|
|
|
|
init: function(settings) {
|
|
|
|
|
if (settings) {
|
|
|
|
|
this.settings = settings;
|
|
|
|
|
}
|
|
|
|
|
init.call(this, this.container, this.settings);
|
|
|
|
|
},
|
|
|
|
|
getThis: function() {
|
|
|
|
|
return this;
|
|
|
|
|
},
|
|
|
|
|
eq: function(n) {
|
|
|
|
|
this.container = $(this.selector).eq(n);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.fn.Xslider = function(settings) {
|
|
|
|
|
return ClassSlider(this, settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.fn.Xslider.sn = {
|
|
|
|
|
defaults: {
|
|
|
|
|
unitDisplayed: 1,
|
|
|
|
|
dir: "H",
|
|
|
|
|
showNav: null,
|
|
|
|
|
navEventType: "mouseenter",
|
|
|
|
|
speed: 500,
|
|
|
|
|
scrollObj: "ul",
|
|
|
|
|
scrollunits: "li",
|
|
|
|
|
curStyle: "current",
|
|
|
|
|
eventType: "click",
|
|
|
|
|
imgInit: 1,
|
|
|
|
|
start: 1,
|
|
|
|
|
numtoMove: 1,
|
|
|
|
|
stepOne: false,
|
|
|
|
|
btnNext: "a.aright",
|
|
|
|
|
btnPrevious: "a.aleft",
|
|
|
|
|
afterEnd: function(e) { },
|
|
|
|
|
beforeStart: function(e) { },
|
|
|
|
|
disableStyle: { previous: "agrayleft", next: "agrayright" },
|
|
|
|
|
navCurStyle: "current"
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
animate: function(obj, w, dir, unitLen, speed, callback, noAnimate) {
|
|
|
|
|
if (dir == "H") {
|
|
|
|
|
if (noAnimate) {
|
|
|
|
|
obj.css({ left: w });
|
|
|
|
|
callback.call(this);
|
|
|
|
|
} else {
|
|
|
|
|
obj.stop().animate({
|
|
|
|
|
left: w
|
|
|
|
|
}, speed, "easeOutQuint", callback);
|
|
|
|
|
}
|
|
|
|
|
} else if (dir == "V") {
|
|
|
|
|
if (noAnimate) {
|
|
|
|
|
obj.css({ top: w });
|
|
|
|
|
callback.call(this);
|
|
|
|
|
} else {
|
|
|
|
|
obj.stop().animate({
|
|
|
|
|
top: w
|
|
|
|
|
}, speed, "easeOutQuint", callback);
|
|
|
|
|
}
|
|
|
|
|
} else if (dir == "F") {
|
|
|
|
|
var curindex = $(this).data("curindex");
|
|
|
|
|
if (noAnimate) {
|
|
|
|
|
obj.children(":visible").hide();
|
|
|
|
|
obj.children().eq(curindex - 1).show();
|
|
|
|
|
} else {
|
|
|
|
|
obj.children(":visible").stop(true, true).fadeOut(120);
|
|
|
|
|
|
|
|
|
|
obj.children().eq(curindex - 1).stop(true, true).fadeIn(speed, callback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (dir == "F2") {
|
|
|
|
|
var curindex = $(this).data("curindex");
|
|
|
|
|
if (noAnimate) {
|
|
|
|
|
obj.children(":visible").hide();
|
|
|
|
|
obj.children().eq(curindex - 1).show();
|
|
|
|
|
} else {
|
|
|
|
|
var runenv = $(this).data("runenv");
|
|
|
|
|
var curobj = $(this).data("curobj");
|
|
|
|
|
runenv.scrollObj.prepend(curobj);
|
|
|
|
|
var len = runenv.scrollunits.length;
|
|
|
|
|
$(runenv.scrollunits.selector).each(function(i, v) {
|
|
|
|
|
$(this).css("z-index", len - i);
|
|
|
|
|
})
|
|
|
|
|
curobj.hide().fadeIn(speed, callback);
|
|
|
|
|
/*obj.children(":visible").css({zIndex:0}).show();
|
|
|
|
|
obj.children().eq(-w / unitLen).hide().css({zIndex:1}).fadeIn(speed, callback);*/
|
|
|
|
|
}
|
|
|
|
|
} else if (dir == "noanim") {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
|
|
window["UI"] = window["UI"] || {};
|
|
|
|
|
UI["Xslider"] = function(s, op) {
|
|
|
|
|
return $(s).Xslider(op);
|
|
|
|
|
}
|