-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
842 lines (711 loc) · 28.6 KB
/
Copy pathscript.js
File metadata and controls
842 lines (711 loc) · 28.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
/* ============================================================================
EMBER CAFÉ – MICRO-INTERACTIONS & ANIMATIONS
Calm, intentional, breathing-like motion
============================================================================ */
// ============================================================================
// 1. NAVIGATION SETTLING EFFECT
// ============================================================================
class NavigationController {
constructor() {
this.nav = document.getElementById('navigation');
this.sections = document.querySelectorAll('section[id]');
this.links = document.querySelectorAll('.nav__link');
this.indicator = document.querySelector('.nav__indicator');
this.init();
}
init() {
window.addEventListener('scroll', () => this.onScroll());
this.links.forEach(link => {
link.addEventListener('click', (e) => this.onLinkClick(e));
});
}
onScroll() {
// Scroll-linked navigation settling effect
const scrollTop = window.scrollY;
// Change nav background opacity based on scroll
if (scrollTop > 100) {
this.nav.classList.add('is-scrolled');
} else {
this.nav.classList.remove('is-scrolled');
}
// Update active section indicator
this.updateActiveSection();
}
updateActiveSection() {
let currentSection = '';
this.sections.forEach(section => {
const sectionTop = section.offsetTop;
if (window.scrollY >= sectionTop - 200) {
currentSection = section.getAttribute('id');
}
});
// Update active link
this.links.forEach(link => {
const href = link.getAttribute('href').slice(1);
if (href === currentSection) {
link.style.color = 'var(--color-primary-dark)';
} else {
link.style.color = '';
}
});
}
onLinkClick(e) {
// Smooth scroll is handled by CSS scroll-behavior
// but we can add haptic feedback if needed
if (navigator.vibrate) {
navigator.vibrate(10);
}
}
}
// ============================================================================
// 2. SCROLL-LINKED "BREATHING" SECTIONS
// ============================================================================
class ScrollBreathingEffect {
constructor() {
this.sections = document.querySelectorAll('section');
this.observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
this.init();
}
init() {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('in-view');
// Subtle padding expansion
entry.target.style.paddingTop =
`calc(${entry.target.style.paddingTop || '3rem'} + 20px)`;
}
});
}, this.observerOptions);
this.sections.forEach(section => observer.observe(section));
}
}
// ============================================================================
// 3. LIVING MENU INTERACTION
// ============================================================================
class MenuController {
constructor() {
this.tabs = document.querySelectorAll('.menu__tab');
this.categories = document.querySelectorAll('.menu__category');
this.init();
}
init() {
this.tabs.forEach((tab, index) => {
tab.addEventListener('click', () => {
this.switchCategory(tab);
});
});
}
switchCategory(clickedTab) {
const category = clickedTab.dataset.category;
// Update active tab with smooth indicator and ARIA attributes
this.tabs.forEach(tab => {
tab.classList.remove('menu__tab--active');
tab.setAttribute('aria-selected', 'false');
});
clickedTab.classList.add('menu__tab--active');
clickedTab.setAttribute('aria-selected', 'true');
// Update visible category with fade and ARIA hidden attribute
this.categories.forEach(cat => {
if (cat.dataset.category === category) {
cat.classList.add('menu__category--active');
cat.removeAttribute('hidden');
// Re-trigger stagger animation
this.staggerMenuItems(cat);
} else {
cat.classList.remove('menu__category--active');
cat.setAttribute('hidden', '');
}
});
// Haptic feedback on mobile
if (navigator.vibrate) {
navigator.vibrate(15);
}
}
staggerMenuItems(container) {
const items = container.querySelectorAll('.menu__item');
items.forEach((item, index) => {
item.style.animationDelay = `${index * 50}ms`;
});
}
}
// ============================================================================
// 4. MOBILE MENU BUTTON PULSE (Only once on page load)
// ============================================================================
class MobileMenuButton {
constructor() {
this.btn = document.getElementById('mobileMenuBtn');
this.mobileNav = document.getElementById('mobileNav');
this.backdrop = document.getElementById('mobileNavBackdrop');
this.init();
}
init() {
// Pulse animation plays once on load (via CSS animation)
this.btn.addEventListener('click', (e) => {
this.toggleMenu(e);
});
// If mobile nav exists, attach link handlers to close the nav on navigation
if (this.mobileNav) {
const links = this.mobileNav.querySelectorAll('a');
links.forEach(link => {
link.addEventListener('click', () => {
// Close nav and update accessibility attributes
this.closeMenu();
// Haptic feedback on selection
if (navigator.vibrate) navigator.vibrate(10);
});
});
}
// Backdrop click closes the nav
if (this.backdrop) {
this.backdrop.addEventListener('click', () => this.closeMenu());
}
// Close on Escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && this.btn.getAttribute('aria-expanded') === 'true') {
this.closeMenu();
}
});
}
toggleMenu() {
const isExpanded = this.btn.getAttribute('aria-expanded') === 'true';
// If we have a mobile-nav element, toggle its visibility and accessibility
if (this.mobileNav) {
if (isExpanded) {
this.closeMenu();
} else {
this.openNav();
}
return;
}
// Fallback behavior: if mobileNav is missing, scroll to #menu (legacy behavior)
this.btn.setAttribute('aria-expanded', isExpanded ? 'false' : 'true');
document.getElementById('menu').scrollIntoView({ behavior: 'smooth' });
setTimeout(() => this.btn.setAttribute('aria-expanded', 'false'), 1000);
if (navigator.vibrate) navigator.vibrate(20);
}
openNav() {
this.btn.setAttribute('aria-expanded', 'true');
this.btn.classList.add('open');
this.mobileNav.classList.add('open');
this.mobileNav.setAttribute('aria-hidden', 'false');
if (this.backdrop) {
this.backdrop.classList.add('open');
this.backdrop.setAttribute('aria-hidden', 'false');
}
// Prevent body scroll while nav open (mobile only)
document.documentElement.style.overflow = 'hidden';
// Move focus to the first link for accessibility
const firstLink = this.mobileNav.querySelector('a');
if (firstLink) firstLink.focus();
// Haptic feedback
if (navigator.vibrate) navigator.vibrate(20);
}
closeMenu() {
this.btn.setAttribute('aria-expanded', 'false');
this.btn.classList.remove('open');
if (this.mobileNav) {
this.mobileNav.classList.remove('open');
this.mobileNav.setAttribute('aria-hidden', 'true');
}
if (this.backdrop) {
this.backdrop.classList.remove('open');
this.backdrop.setAttribute('aria-hidden', 'true');
}
// Restore body scroll
document.documentElement.style.overflow = '';
// Return focus to the button for keyboard users
this.btn.focus();
}
}
// ============================================================================
// 5. HOVER LIFT EFFECTS (Cards)
// ============================================================================
class HoverLiftEffect {
constructor() {
this.cards = document.querySelectorAll('.signature__card');
this.init();
}
init() {
this.cards.forEach(card => {
card.addEventListener('mouseenter', () => {
card.style.transform = 'translateY(-8px)';
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'translateY(0)';
});
});
}
}
// ============================================================================
// 6. PAGE-TURN IMAGE TRANSITIONS
// ============================================================================
class PageTurnTransition {
constructor() {
this.spaceImages = document.querySelectorAll('.space__image-wrapper');
this.init();
}
init() {
this.spaceImages.forEach(img => {
img.addEventListener('mouseenter', () => {
this.applyPageTurnEffect(img);
});
});
}
applyPageTurnEffect(element) {
const image = element.querySelector('img');
if (image) {
image.style.transform = 'scale(1.03) rotate(1deg)';
image.style.boxShadow = '0 12px 32px rgba(0,0,0,0.1)';
}
}
}
// ============================================================================
// 7. LAZY LOADING IMAGES WITH FADE-IN
// ============================================================================
class LazyLoadImages {
constructor() {
this.images = document.querySelectorAll('img[loading="lazy"]');
this.init();
}
init() {
if ('IntersectionObserver' in window) {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
this.loadImage(entry.target);
observer.unobserve(entry.target);
}
});
}, {
rootMargin: '400px'
});
this.images.forEach(img => observer.observe(img));
} else {
// Fallback for older browsers
this.images.forEach(img => this.loadImage(img));
}
}
loadImage(img) {
// Check if image is already loaded (cached or local)
if (img.complete && img.naturalHeight !== 0) {
// Image already loaded, show immediately
img.style.opacity = '1';
} else {
// Image not loaded yet, fade in when ready
img.style.opacity = '0';
img.style.transition = 'opacity 600ms cubic-bezier(0.4, 0, 0.2, 1)';
img.onload = () => {
img.style.opacity = '1';
};
img.onerror = () => {
// Fallback image on load error
img.style.opacity = '0.5';
};
}
}
}
// ============================================================================
// 8. SMOOTH SCROLL WITH INTENTIONAL PAUSES
// ============================================================================
class ScrollPaceController {
constructor() {
this.sections = document.querySelectorAll('section');
this.init();
}
init() {
// CSS scroll-behavior: smooth handles most of this
// This adds subtle detection for momentum scrolling pauses
let scrollTimeout;
window.addEventListener('scroll', () => {
clearTimeout(scrollTimeout);
document.body.style.scrollBehavior = 'auto';
scrollTimeout = setTimeout(() => {
document.body.style.scrollBehavior = 'smooth';
}, 150);
});
}
}
// ============================================================================
// 9. TYPOGRAPHY MICRO-DETAILS
// ============================================================================
class TypographyEffects {
constructor() {
this.titles = document.querySelectorAll('h2');
this.init();
}
init() {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('title-active');
}
});
}, {
threshold: 0.5
});
this.titles.forEach(title => {
observer.observe(title);
});
}
}
// ============================================================================
// 10. TOUCH INTERACTIONS FOR MOBILE
// ============================================================================
class TouchInteractions {
constructor() {
this.cards = document.querySelectorAll('.signature__card');
this.touchStartX = 0;
this.touchEndX = 0;
this.init();
}
init() {
document.addEventListener('touchstart', (e) => {
this.touchStartX = e.changedTouches[0].screenX;
}, false);
document.addEventListener('touchend', (e) => {
this.touchEndX = e.changedTouches[0].screenX;
this.handleSwipe();
}, false);
}
handleSwipe() {
const diff = this.touchStartX - this.touchEndX;
// Left swipe
if (Math.abs(diff) > 50) {
if (navigator.vibrate) {
navigator.vibrate(10);
}
}
}
}
// ============================================================================
// 11. REDUCED MOTION DETECTION
// ============================================================================
class ReducedMotionHandler {
constructor() {
this.prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (this.prefersReducedMotion) {
this.disableAnimations();
}
}
disableAnimations() {
const style = document.createElement('style');
style.textContent = `
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
`;
document.head.appendChild(style);
}
}
// ============================================================================
// 12. ACCESSIBILITY FOCUS MANAGEMENT
// ============================================================================
class AccessibilityManager {
constructor() {
this.init();
}
init() {
// Show focus outline on keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'Tab') {
document.body.classList.add('keyboard-nav');
}
});
document.addEventListener('mousedown', () => {
document.body.classList.remove('keyboard-nav');
});
}
}
// ============================================================================
// 13. INITIALIZATION
// ============================================================================
document.addEventListener('DOMContentLoaded', () => {
// Initialize all controllers
new NavigationController();
new ScrollBreathingEffect();
new MenuController();
new MobileMenuButton();
new HoverLiftEffect();
new PageTurnTransition();
new LazyLoadImages();
new ScrollPaceController();
new TypographyEffects();
new TouchInteractions();
new ReducedMotionHandler();
new AccessibilityManager();
new ContactFormController();
// Log initialization (development only)
console.log('✨ Ember Café – Micro-interactions initialized');
});
// ============================================================================
// 14. PERFORMANCE OPTIMIZATION
// ============================================================================
// Debounce function for scroll events
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Throttle function for high-frequency events
function throttle(func, limit) {
let inThrottle;
return function(...args) {
if (!inThrottle) {
func.apply(this, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
};
}
/* ============================
CONTACT FORM HANDLER
============================ */
class ContactFormController {
constructor() {
this.form = document.getElementById('contact-form');
if (!this.form) return;
this.nameInput = document.getElementById('name');
this.emailInput = document.getElementById('email');
this.phoneInput = document.getElementById('phone');
this.inquiryInput = document.getElementById('inquiry-type');
this.messageInput = document.getElementById('message');
this.submitBtn = document.getElementById('submit-btn');
this.formMessage = document.getElementById('form-message');
this.charCount = document.getElementById('char-count');
this.nameError = document.getElementById('name-error');
this.emailError = document.getElementById('email-error');
this.inquiryError = document.getElementById('inquiry-error');
this.messageError = document.getElementById('message-error');
this.init();
}
init() {
// Character counter for message field
this.messageInput.addEventListener('input', () => {
this.charCount.textContent = this.messageInput.value.length;
});
// Real-time validation on blur for Name field
this.nameInput.addEventListener('blur', () => {
if (!this.nameInput.value.trim()) {
this.showError(this.nameInput, this.nameError, '✕ Name is required');
} else {
this.clearError(this.nameInput, this.nameError);
}
});
this.nameInput.addEventListener('input', () => {
if (this.nameInput.value.trim() && this.nameInput.classList.contains('error')) {
this.clearError(this.nameInput, this.nameError);
}
});
// Real-time validation on blur for Email field
this.emailInput.addEventListener('blur', () => {
if (!this.emailInput.value) {
this.showError(this.emailInput, this.emailError, '✕ Email is required');
} else if (!this.validateEmail(this.emailInput.value)) {
this.showError(this.emailInput, this.emailError, '✕ Enter a valid email (e.g., user@example.com)');
} else {
this.clearError(this.emailInput, this.emailError);
}
});
this.emailInput.addEventListener('input', () => {
if (this.validateEmail(this.emailInput.value) && this.emailInput.classList.contains('error')) {
this.clearError(this.emailInput, this.emailError);
}
});
// Real-time validation for inquiry type dropdown
this.inquiryInput.addEventListener('change', () => {
if (this.inquiryInput.value) {
this.clearError(this.inquiryInput, this.inquiryError);
}
});
// Real-time validation for message field
this.messageInput.addEventListener('blur', () => {
if (!this.messageInput.value.trim()) {
this.showError(this.messageInput, this.messageError, '✕ Message is required');
} else if (this.messageInput.value.trim().length < 10) {
this.showError(this.messageInput, this.messageError, '✕ Message must be at least 10 characters');
} else {
this.clearError(this.messageInput, this.messageError);
}
});
this.messageInput.addEventListener('input', () => {
const value = this.messageInput.value.trim();
if (value && value.length >= 10 && this.messageInput.classList.contains('error')) {
this.clearError(this.messageInput, this.messageError);
}
});
// Form submission
this.form.addEventListener('submit', (e) => {
e.preventDefault();
this.handleSubmit();
});
}
validateEmail(email) {
return email && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
validateForm() {
let isValid = true;
// Name validation
if (!this.nameInput.value.trim()) {
this.showError(this.nameInput, this.nameError, '✕ Name is required');
isValid = false;
} else {
this.clearError(this.nameInput, this.nameError);
}
// Email validation
if (!this.emailInput.value.trim()) {
this.showError(this.emailInput, this.emailError, '✕ Email is required');
isValid = false;
} else if (!this.validateEmail(this.emailInput.value)) {
this.showError(this.emailInput, this.emailError, '✕ Enter a valid email address');
isValid = false;
} else {
this.clearError(this.emailInput, this.emailError);
}
// Inquiry type validation
if (!this.inquiryInput.value) {
this.showError(this.inquiryInput, this.inquiryError, '✕ Please select an inquiry type');
isValid = false;
} else {
this.clearError(this.inquiryInput, this.inquiryError);
}
// Message validation
if (!this.messageInput.value.trim()) {
this.showError(this.messageInput, this.messageError, '✕ Message is required');
isValid = false;
} else if (this.messageInput.value.trim().length < 10) {
this.showError(this.messageInput, this.messageError, '✕ Message must be at least 10 characters');
isValid = false;
} else {
this.clearError(this.messageInput, this.messageError);
}
// Scroll to first error if validation fails
if (!isValid) {
const firstError = this.form.querySelector('.error');
if (firstError) {
firstError.scrollIntoView({ behavior: 'smooth', block: 'center' });
firstError.focus();
}
}
return isValid;
}
showError(input, errorElement, message) {
input.classList.add('error');
input.setAttribute('aria-invalid', 'true');
if (errorElement && errorElement.id) {
input.setAttribute('aria-describedby', errorElement.id);
}
if (errorElement) {
errorElement.textContent = message;
errorElement.classList.add('show');
}
}
clearError(input, errorElement) {
input.classList.remove('error');
input.removeAttribute('aria-invalid');
if (errorElement && errorElement.id && input.getAttribute('aria-describedby') === errorElement.id) {
input.removeAttribute('aria-describedby');
}
if (errorElement) {
errorElement.textContent = '';
errorElement.classList.remove('show');
}
}
async handleSubmit() {
// Hide any previous messages
this.formMessage.style.display = 'none';
this.formMessage.classList.remove('success', 'error');
// Validate form
if (!this.validateForm()) {
return;
}
// Show loading state
this.setLoadingState(true);
try {
// Build payload for Web3Forms
const formData = new FormData(this.form);
const inquiryText = this.inquiryInput.options[this.inquiryInput.selectedIndex].text;
formData.set('subject', `New Contact – ${inquiryText}`);
formData.set('from_name', this.nameInput.value.trim());
formData.set('from_email', this.emailInput.value.trim());
formData.set('phone', this.phoneInput.value.trim() || 'Not provided');
formData.set('inquiry_type', inquiryText);
formData.set('message', this.messageInput.value.trim());
const json = Object.fromEntries(formData);
const response = await fetch('https://api.web3forms.com/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify(json)
});
const data = await response.json();
if (data.success) {
// Track successful submission in GA4
if (typeof gtag !== 'undefined') {
gtag('event', 'form_submission', {
event_category: 'Contact',
event_label: inquiryText,
value: 1
});
}
// Show success message
this.showMessage('Thank you! Your message has been sent successfully. We\'ll get back to you soon.', 'success');
// Reset form
this.form.reset();
this.charCount.textContent = '0';
} else {
console.error('Web3Forms error:', data);
// Track error in GA4
if (typeof gtag !== 'undefined') {
gtag('event', 'form_error', {
event_category: 'Contact',
event_label: data.message || 'Unknown error',
value: 0
});
}
this.showMessage('Oops! Something went wrong. Please try again or email us directly at hello@embercafe.com', 'error');
}
} catch (error) {
console.error('Web3Forms request failed:', error);
if (typeof gtag !== 'undefined') {
gtag('event', 'form_error', {
event_category: 'Contact',
event_label: error.message || 'Network error',
value: 0
});
}
this.showMessage('Network error. Please try again in a moment or email us at hello@embercafe.com', 'error');
} finally {
this.setLoadingState(false);
}
}
setLoadingState(isLoading) {
if (isLoading) {
this.submitBtn.textContent = 'Sending...';
this.submitBtn.disabled = true;
} else {
this.submitBtn.textContent = 'Send Message';
this.submitBtn.disabled = false;
}
}
showMessage(text, type) {
this.formMessage.textContent = text;
this.formMessage.classList.add(type);
this.formMessage.style.display = 'block';
// Scroll to message
this.formMessage.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
}