SoFunction
Updated on 2025-04-14

JavaScript picture switching display effect alibaba expansion version page 2/3


var $ = function (id) {
return "string" == typeof id ? (id) : id;
};

var Class = {
create: function() {
return function() {
(this, arguments);
}
}
}

= function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}

var TransformView = ();
= {
//Container object, sliding object, switching parameters, switching quantity
initialize: function(container, slider, parameter, count, options) {
if(parameter <= 0 || count <= 0) return;
var oContainer = $(container), oSlider = $(slider), oThis = this;

= 0;//Current index

this._timer = null;//Timer
this._slider = oSlider;//Sliding object
this._parameter = parameter;//Switch parameters
this._count = count || 0;//Switch quantity
this._target = 0;//Target parameter

(options);

= !!;
= ();
= ();
= !!;
= ();
= ;
= ;

= "hidden";
= "relative";

= "absolute";
= = 0;
},
//Set default properties
SetOptions: function(options) {
= {//Default value
Up: true, //Whether it is up (otherwise it is left)
Step: 5,//Sliding change rate
Time: 10,//Sliding delay
Auto: true, //Is it automatic conversion
Pause: 2000, //Pause time (valid when Auto is true)
onStart: function(){},//Execute when starting conversion
onFinish: function(){}//Execute when the conversion is completed
};
(, options || {});
},
//Start switch settings
Start: function() {
if( < 0){
= this._count - 1;
} else if ( >= this._count){ = 0; }

this._target = -1 * this._parameter * ;
();
();
},
//move
Move: function() {
clearTimeout(this._timer);
var oThis = this, style = ? "top" : "left", iNow = parseInt(this._slider.style[style]) || 0, iStep = (this._target, iNow);

if (iStep != 0) {
this._slider.style[style] = (iNow + iStep) + "px";
this._timer = setTimeout(function(){ (); }, );
} else {
this._slider.style[style] = this._target + "px";
();
if () { this._timer = setTimeout(function(){ ++; (); }, ); }
}
},
//Get step size
GetStep: function(iTarget, iNow) {
var iStep = (iTarget - iNow) / ;
if (iStep == 0) return 0;
if ((iStep) < 1) return (iStep > 0 ? 1 : -1);
return iStep;
},
//stop
Stop: function(iTarget, iNow) {
clearTimeout(this._timer);
this._slider.style[ ? "top" : "left"] = this._target + "px";
}
};