View Full Version : CMotion - Skip to start/end/middle

09-29-2006, 11:06 AM
1) Script Title: CMotion Image Gallery

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/cmotiongallery.htm

3) Describe problem: Love this script & it's working really well. Would like to add to it but my javascript knowledge just isn't up to the task.

As I'm using it to display full size images rather than thumbnails & there are quite a few images in the gallery it would be nice to offer the ability to skip to the begining/end/middle of the gallery.

Since the startpos variable is already set up & I'd basically just be wanting to allow the user to set that is this a fairly easy task?

Thanks in advance for any help/responses.

09-29-2006, 04:37 PM
from the Demo Page:
Image train may be started left, center or right.

From motiongallery.js -

//1) Set width of the "neutral" area in the center of the gallery.
var restarea=6;
//2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed=7;
//3) Set to maximum width for gallery - must be less than the actual length of the image train.
var maxwidth=1000;
//4) Set to 1 for left start, 0 for right, 2 for center.
var startpos=0;
//5) Set message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg='<span style="font-size: 11px;">End of Gallery</span>';

10-02-2006, 09:21 AM
As I mentioned, I found that variable, what I'm hoping to do though is to use it to allow people browsing the site to skip around the gallery...

10-02-2006, 04:05 PM
I didn't get that, sorry. Yes, you can jump around the various starting positions fairly easily:

<span onclick="startpos=0;onresize();">Jump to Beginning</span>

For the two other positions - use 1 for the end, 2 for the center.

You can also pick your own custom spots in the image train by doing:


Use whatever number you like, it represents the number of pixels from the starpos=0 point that you want your image train to assume.

10-03-2006, 09:40 AM
Thank you :) That was exactly what I was looking for.

Works in Firefox... can't seem to get it to work in IE though, any clue why?

10-03-2006, 03:08 PM
Darn that IE, always has to be different. A call to onresize(); in the script works just fine but, as an onclick event doesn't. There is an easy enough way around it though. Change this in the script:



function cresize(){

and below that function, put this (red):

function cresize(){
if (typeof motioncontainer!=='undefined'&&motioncontainer.filters){
motioncontainer.style.width=Math.min(motioncontainer.offsetWidth, maxwidth)+'px';
cross_scroll.style.left=startpos? (menuwidth-actualwidth)/startpos+'px' : 0;

Now you can use this:

<span onclick="startpos=0;cresize();">Jump to Beginning</span>

and similar to do this for all browsers that support the gallery.

10-04-2006, 07:54 AM
:D Thank you so much, you're an absolute star!!!

That works perfectly.