/    Sign up×
Community /Pin to ProfileBookmark

Scaling Images in an array

I have an array that I’m using for a picture scroller and I want to have it presize my pictures. Is there a function that can do that? I understand programming, but I haven’t really looked at javascript that much. The code is:

var Slides = new Array(‘photos/bjpennkofactory.jpg’,’photos/cabbagekofactory.jpg’,’photos/danakofactory.jpg’,’photos/erin_t2.jpg’,’photos/forrestgriffith.jpg’,
‘photos/hammerkofactory.jpg’,’photos/jeremy_horn_KOfactory.jpg’,’photos/joerogankofactory.jpg’,’photos/kevinnaskkofactory.jpg’,’photos/mikenchuckliddel.jpg’,’photos/wessimmskofactory.jpg’,’photos/ufc_crew.jpg’);

function CacheImage(ImageSource) {
var ImageObject = new Image();
ImageObject.src = ImageSource;
return ImageObject;
}

function ShowSlide(Direction) {
if (SlideReady) {
NextSlide = CurrentSlide + Direction;
document.SlideShow.Previous.disabled = (NextSlide == 0);
document.SlideShow.Next.disabled = (NextSlide == (Slides.length-1));

if ((NextSlide >= 0) && (NextSlide < Slides.length)) {
document.images[‘Screen’].src = Slides[NextSlide].src;
CurrentSlide = NextSlide++;
Message = ‘Picture ‘ + (CurrentSlide+1) + ‘ of ‘ + Slides.length;
self.defaultStatus = Message;
if (Direction == 1) CacheNextSlide();
}
return true;
}
}

function Download() {
if (Slides[NextSlide].complete) {
SlideReady = true;
self.defaultStatus = Message;
}
else setTimeout(“Download()”, 100);
return true;
}

function CacheNextSlide() {
if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == ‘string’))
{
SlideReady = false;
self.defaultStatus = ‘Downloading next picture…’;
Slides[NextSlide] = CacheImage(Slides[NextSlide]);
Download();
}
return true;
}

function StartSlideShow() {
CurrentSlide = -1;
Slides[0] = CacheImage(Slides[0]);
SlideReady = true;
ShowSlide(1);
}

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @hadwahnos spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...