-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestts.html
More file actions
471 lines (411 loc) · 14.4 KB
/
testts.html
File metadata and controls
471 lines (411 loc) · 14.4 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
<html><head><base href="https://angular-gsap-docs.com/">
<title>Angular GSAP Documentation</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');
:root {
--primary-color: #3f51b5;
--secondary-color: #ff4081;
--bg-color: #f5f5f5;
--text-color: #333;
--code-bg: #f0f0f0;
}
body, html {
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
scroll-behavior: smooth;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
header {
background-color: var(--primary-color);
color: white;
padding: 20px 0;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
position: fixed;
width: 100%;
top: 0;
z-index: 1000;
}
h1 {
margin: 0;
font-size: 2.5em;
text-align: center;
}
nav {
background-color: white;
padding: 10px 0;
position: fixed;
width: 100%;
top: 70px;
z-index: 999;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
nav ul {
list-style-type: none;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
flex-wrap: wrap;
}
nav ul li {
margin: 5px 15px;
}
nav ul li a {
color: var(--primary-color);
text-decoration: none;
font-weight: 600;
transition: color 0.3s ease;
padding: 5px 10px;
border-radius: 20px;
}
nav ul li a:hover, nav ul li a.active {
background-color: var(--primary-color);
color: white;
}
.content {
background-color: white;
padding: 30px;
margin-top: 140px;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
pre {
background-color: var(--code-bg);
border: 1px solid #ddd;
border-radius: 8px;
padding: 15px;
overflow-x: auto;
}
.example {
margin-bottom: 40px;
border: 1px solid #e0e0e0;
border-radius: 8px;
overflow: hidden;
}
.demo-area {
height: 300px;
background-color: #fafafa;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.demo-box {
width: 50px;
height: 50px;
background-color: var(--primary-color);
}
button {
background-color: var(--secondary-color);
color: white;
border: none;
padding: 10px 20px;
border-radius: 25px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
font-weight: 600;
margin: 10px;
}
button:hover {
background-color: #e91e63;
transform: translateY(-2px);
}
.page {
min-height: 100vh;
padding-top: 140px;
}
#svg-demo {
width: 100%;
height: 100%;
}
.scroll-indicator {
position: fixed;
top: 120px;
right: 20px;
width: 50px;
height: 50px;
background-color: var(--secondary-color);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
z-index: 1001;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.demo-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-top: 20px;
}
.demo-card {
background-color: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.demo-card:hover {
transform: translateY(-5px);
}
.demo-card-content {
padding: 15px;
}
.demo-card h3 {
margin-top: 0;
color: var(--primary-color);
}
.loading {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
font-size: 1.2em;
color: var(--primary-color);
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/ScrollTrigger.min.js"></script>
</head>
<body>
<header>
<h1>Angular GSAP Documentation</h1>
</header>
<nav id="main-nav">
<ul>
<li><a href="#introduction" class="active">Introduction</a></li>
<li><a href="#basic-usage">Basic Usage</a></li>
<li><a href="#scroll-trigger">ScrollTrigger</a></li>
<li><a href="#svg-animation">SVG Animation</a></li>
<li><a href="#demo-gallery">Demo Gallery</a></li>
</ul>
</nav>
<div class="scroll-indicator" id="scrollIndicator">0%</div>
<div class="container">
<div class="content">
<section id="introduction" class="page">
<h2>Introduction</h2>
<p>GSAP (GreenSock Animation Platform) is a powerful animation library that can be seamlessly integrated with Angular to create stunning animations. This documentation will guide you through the process of using GSAP in your Angular projects.</p>
<p>To get started with GSAP in your Angular project, you need to install it via npm:</p>
<pre><code>npm install gsap @types/gsap</code></pre>
</section>
<section id="basic-usage" class="page">
<h2>Basic Usage</h2>
<p>Here's a simple example of how to use GSAP in an Angular component:</p>
<div class="example">
<div class="demo-area">
<div class="demo-box" id="basic-demo"></div>
</div>
<pre><code>import { Component, OnInit } from '@angular/core';
import { gsap } from 'gsap';
@Component({
selector: 'app-basic-animation',
template: '<div class="box"></div>'
})
export class BasicAnimationComponent implements OnInit {
ngOnInit() {
gsap.to('.box', { duration: 2, x: 100, rotation: 360 });
}
}</code></pre>
<button onclick="runBasicDemo()">Run Demo</button>
</div>
</section>
<section id="scroll-trigger" class="page">
<h2>ScrollTrigger</h2>
<p>GSAP's ScrollTrigger plugin allows you to create scroll-based animations easily:</p>
<div class="example">
<div class="demo-area" style="height: 400px;">
<div class="demo-box" id="scroll-demo"></div>
</div>
<pre><code>import { Component, OnInit } from '@angular/core';
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
gsap.registerPlugin(ScrollTrigger);
@Component({
selector: 'app-scroll-animation',
template: '<div class="box"></div>'
})
export class ScrollAnimationComponent implements OnInit {
ngOnInit() {
gsap.to('.box', {
x: 200,
rotation: 360,
duration: 3,
scrollTrigger: {
trigger: '.box',
start: 'top center',
end: 'bottom center',
scrub: true
}
});
}
}</code></pre>
<p>Scroll down to see the animation in action!</p>
</div>
</section>
<section id="svg-animation" class="page">
<h2>SVG Animation</h2>
<p>GSAP excels at animating SVG elements. Here's an example:</p>
<div class="example">
<div class="demo-area">
<svg id="svg-demo" viewBox="0 0 100 100">
<circle cx="50" cy="50" r="30" fill="#3f51b5" />
<rect x="20" y="20" width="20" height="20" fill="#ff4081" />
<polygon points="80,20 90,40 70,40" fill="#4CAF50" />
</svg>
</div>
<pre><code>import { Component, OnInit } from '@angular/core';
import { gsap } from 'gsap';
@Component({
selector: 'app-svg-animation',
template: `
<svg viewBox="0 0 100 100">
<circle cx="50" cy="50" r="30" fill="#3f51b5" />
<rect x="20" y="20" width="20" height="20" fill="#ff4081" />
<polygon points="80,20 90,40 70,40" fill="#4CAF50" />
</svg>
`
})
export class SvgAnimationComponent implements OnInit {
ngOnInit() {
gsap.to('circle', { duration: 2, r: 40, repeat: -1, yoyo: true });
gsap.to('rect', { duration: 1, x: 60, repeat: -1, yoyo: true });
gsap.to('polygon', { duration: 1.5, rotation: 360, transformOrigin: '50% 50%', repeat: -1 });
}
}</code></pre>
<button onclick="runSvgDemo()">Run Demo</button>
</div>
</section>
<section id="demo-gallery" class="page">
<h2>Demo Gallery</h2>
<p>Explore our extensive collection of GSAP animations:</p>
<div id="demo-container" class="demo-grid">
<div class="loading">Loading demos...</div>
</div>
</section>
</div>
</div>
<script>
gsap.registerPlugin(ScrollTrigger);
function runBasicDemo() {
gsap.to('#basic-demo', { duration: 2, x: 100, rotation: 360, ease: 'bounce.out' });
}
function runSvgDemo() {
gsap.to('#svg-demo circle', { duration: 2, attr: { r: 40 }, repeat: -1, yoyo: true });
gsap.to('#svg-demo rect', { duration: 1, x: 60, repeat: -1, yoyo: true });
gsap.to('#svg-demo polygon', { duration: 1.5, rotation: 360, transformOrigin: '50% 50%', repeat: -1 });
}
// ScrollTrigger demo
gsap.to('#scroll-demo', {
x: 200,
rotation: 360,
duration: 3,
scrollTrigger: {
trigger: '#scroll-demo',
start: 'top center',
end: 'bottom center',
scrub: true
}
});
// Smooth scrolling
const smoothScroll = (target) => {
gsap.to(window, {duration: 1, scrollTo: target, ease: "power2.inOut"});
};
document.querySelectorAll('nav a').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelectorAll('nav a').forEach(a => a.classList.remove('active'));
this.classList.add('active');
const target = this.getAttribute('href');
smoothScroll(target);
});
});
// Scroll indicator
gsap.to("#scrollIndicator", {
textContent: () => Math.round((window.scrollY / (document.documentElement.scrollHeight - window.innerHeight)) * 100) + "%",
ease: "none",
scrollTrigger: {
start: 0,
end: "max",
scrub: 0.5
}
});
// Fetch and display demos
const demoContainer = document.getElementById('demo-container');
function createDemoCard(demo) {
const card = document.createElement('div');
card.className = 'demo-card';
const demoArea = document.createElement('div');
demoArea.className = 'demo-area';
demoArea.id = `demo-${demo.id}`;
const content = document.createElement('div');
content.className = 'demo-card-content';
const title = document.createElement('h3');
title.textContent = demo.title;
const runButton = document.createElement('button');
runButton.textContent = 'Run Demo';
runButton.onclick = () => runDemo(demo);
content.appendChild(title);
content.appendChild(runButton);
card.appendChild(demoArea);
card.appendChild(content);
return card;
}
function runDemo(demo) {
const target = `#demo-${demo.id}`;
gsap.set(target, { clearProps: 'all' });
eval(demo.code);
}
// Simulating API call to fetch demos
function fetchDemos() {
return new Promise(resolve => {
setTimeout(() => {
resolve([
{ id: 1, title: 'Bounce Effect', code: `gsap.to('${target}', { y: -50, duration: 1, ease: 'bounce.out', repeat: -1, yoyo: true });` },
{ id: 2, title: 'Color Change', code: `gsap.to('${target}', { backgroundColor: '#ff4081', duration: 2, repeat: -1, yoyo: true });` },
{ id: 3, title: 'Rotate and Scale', code: `gsap.to('${target}', { rotation: 360, scale: 1.5, duration: 2, repeat: -1, yoyo: true });` },
{ id: 4, title: 'Fade In/Out', code: `gsap.to('${target}', { opacity: 0, duration: 1, repeat: -1, yoyo: true });` },
{ id: 5, title: 'Elastic Movement', code: `gsap.to('${target}', { x: 100, duration: 2, ease: 'elastic.out(1, 0.3)', repeat: -1, yoyo: true });` },
// Add more demo objects here...
]);
}, 1000);
});
}
fetchDemos().then(demos => {
demoContainer.innerHTML = '';
demos.forEach(demo => {
const card = createDemoCard(demo);
demoContainer.appendChild(card);
});
});
// Highlight active nav item on scroll
const navItems = document.querySelectorAll('nav a');
const sections = document.querySelectorAll('.page');
window.addEventListener('scroll', () => {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (pageYOffset >= sectionTop - 150) {
current = section.getAttribute('id');
}
});
navItems.forEach(item => {
item.classList.remove('active');
if (item.getAttribute('href').slice(1) === current) {
item.classList.add('active');
}
});
});
</script>
</body>
</html>