Public Access
Remove initial background image — hero starts clean with gradient only, city slides in on first swap
This commit is contained in:
@@ -535,16 +535,15 @@ var si = 0,
|
||||
bg.className = 'hero-bg';
|
||||
hero.insertBefore(bg, hero.firstChild);
|
||||
}
|
||||
/* Old slide — starts at current position, slides out right */
|
||||
var oldEl = document.createElement('div');
|
||||
oldEl.className = 'hero-bg-slide old';
|
||||
oldEl.style.backgroundImage = "url('images/city-amsterdam.jpg')";
|
||||
bg.appendChild(oldEl);
|
||||
|
||||
var hasExisting = bg.children.length > 0;
|
||||
|
||||
/* New slide — starts off-screen right, slides in */
|
||||
var newEl = document.createElement('div');
|
||||
newEl.className = 'hero-bg-slide new';
|
||||
newEl.className = 'hero-bg-slide';
|
||||
newEl.style.backgroundImage = "url('" + heroImages[best.host] + "')";
|
||||
bg.appendChild(newEl);
|
||||
|
||||
/* Label slides in from right */
|
||||
var label = document.createElement('div');
|
||||
label.className = 'hero-city-label';
|
||||
@@ -552,16 +551,23 @@ var si = 0,
|
||||
hero.appendChild(label);
|
||||
|
||||
/* GSAP timeline — 3x slower */
|
||||
gsap.set(oldEl, { x: '0%' });
|
||||
gsap.set(newEl, { x: '100%' });
|
||||
gsap.set(label, { x: '150%' });
|
||||
|
||||
var tl = gsap.timeline({
|
||||
onComplete: function() { oldEl.remove(); }
|
||||
});
|
||||
tl.to(oldEl, { x: '100%', duration: 3, ease: 'power2.out' }, 0)
|
||||
.to(newEl, { x: '0%', duration: 3, ease: 'power2.out' }, 0)
|
||||
.to(label, { x: '0%', duration: 2.5, ease: 'power2.out' }, 0.3);
|
||||
var tl = gsap.timeline();
|
||||
if (hasExisting) {
|
||||
/* Carousel: old slides out right, new slides in */
|
||||
var oldEl = bg.children[0];
|
||||
gsap.set(oldEl, { x: '0%' });
|
||||
tl.to(oldEl, { x: '100%', duration: 3, ease: 'power2.out' }, 0)
|
||||
.to(newEl, { x: '0%', duration: 3, ease: 'power2.out' }, 0)
|
||||
.to(label, { x: '0%', duration: 2.5, ease: 'power2.out' }, 0.3)
|
||||
.call(function() { oldEl.remove(); });
|
||||
} else {
|
||||
/* First time: just slide new in from right */
|
||||
tl.to(newEl, { x: '0%', duration: 3, ease: 'power2.out' }, 0)
|
||||
.to(label, { x: '0%', duration: 2.5, ease: 'power2.out' }, 0.3);
|
||||
}
|
||||
};
|
||||
img.src = heroImages[best.host];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user