Skip to content

Commit ebbd6ea

Browse files
committed
update to v1.1.0
1 parent abe2140 commit ebbd6ea

File tree

5 files changed

+186
-25
lines changed

5 files changed

+186
-25
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# VSCode settings
2+
.vscode/
3+
14
# Dependencies
25
node_modules/
36

@@ -19,4 +22,6 @@ demo/
1922
index.html
2023
demo.js
2124
styles.css
22-
index copy.html
25+
index copy.html
26+
27+
depthtext SAUVEGARDE.ts

CHANGELOG.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,38 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.1.0] - 2025-01-21
6+
7+
### Added
8+
9+
- **New `addClass` option**: Add custom CSS classes to all depth layers for advanced styling control
10+
- Supports single or multiple classes (space-separated)
11+
- Available via JavaScript API: `addClass: "my-class"`
12+
- Available via HTML attribute: `data-depth-add-class="my-class"`
13+
- Enables gradient effects, animations, and custom styling per instance
14+
- Improved class normalization to handle arrays and multiple whitespace formats
15+
16+
### Changed
17+
18+
- Enhanced options validation to support the new `addClass` parameter
19+
- Updated layer creation logic to apply custom classes while maintaining base `depthtext-layer` class
20+
21+
### Technical
22+
23+
- Added `normalizeAddClass()` helper function for robust class string handling
24+
- Extended `DepthTextOptions` interface with `addClass` property
25+
- Updated `DEPTHTEXT_DEFAULTS` to include `addClass: ""`
26+
527
## [1.0.0] - 2025-11-19
628

729
### Added
8-
- Initial release of **DepthText**.
9-
- High-performance 3D layered text rendering.
10-
- Interactive depth effects with pointer and scroll events.
11-
- Configurable depth, layers, direction, and rotation.
12-
- Automatic initialization via `data-depth` attributes.
13-
- TypeScript support with full type definitions.
14-
- ESM, CJS, and IIFE (Global) build artifacts.
15-
- Motion smoothing (lerp) for fluid pointer interaction.
16-
- Accessibility features (`aria-hidden` layers).
30+
31+
- Initial release of **DepthText**
32+
- High-performance 3D layered text rendering
33+
- Interactive depth effects with pointer and scroll events
34+
- Configurable depth, layers, direction, and rotation
35+
- Automatic initialization via `data-depth` attributes
36+
- TypeScript support with full type definitions
37+
- ESM, CJS, and IIFE (Global) build artifacts
38+
- Motion smoothing (lerp) for fluid pointer interaction
39+
- Accessibility features (`aria-hidden` layers)

README.md

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
![Animation](./demo.png)
2+
13
# DepthText
24

35
DepthText is a lightweight, dependency-free JavaScript library that creates smooth multi-layer 3D text with depth, parallax, and interactive rotation.
@@ -18,6 +20,7 @@ It is the spiritual successor of ztext.js, but rewritten from scratch with a cle
1820
- 🔥 **No dependencies**, only 4–6 KB minified
1921
- 📦 Works with bundlers, ES modules, and browsers
2022
- 🖼️ **Supports images, SVGs, and emojis** within text content
23+
- 🎭 **Custom CSS classes** for advanced styling control
2124

2225
---
2326

@@ -75,6 +78,7 @@ DepthText can be configured using either:
7578
| `data-depth-fade` | boolean | `false` | Fade layers as depth increases |
7679
| `data-depth-eventdirection` | number | `1` | Invert pointer/scroll direction |
7780
| `data-depth-eventrotation` | number | `20` | Max rotation angle on interaction |
81+
| `data-depth-add-class` | string | `""` | Custom CSS class(es) to add to each layer |
7882

7983
---
8084

@@ -89,11 +93,93 @@ const instance = new DepthTextInstance(element, {
8993
fade: false,
9094
event: "pointer",
9195
eventRotation: 20,
96+
addClass: "my-custom-class", // New option for custom styling
9297
});
9398
```
9499

95100
---
96101

102+
## 🎨 Custom Styling with `addClass`
103+
104+
The new `addClass` option allows you to apply custom CSS classes to all depth layers for advanced styling control.
105+
106+
### Basic Usage
107+
108+
```html
109+
<h1 class="depthtext" data-depth="10" data-depth-event="pointer" data-depth-add-class="gradient-text">Stylized Text</h1>
110+
```
111+
112+
```css
113+
.gradient-text {
114+
background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
115+
-webkit-background-clip: text;
116+
-webkit-text-fill-color: transparent;
117+
background-clip: text;
118+
}
119+
```
120+
121+
### Multiple Classes
122+
123+
You can add multiple classes separated by spaces:
124+
125+
```js
126+
new DepthTextInstance(element, {
127+
addClass: "gradient-text shadow-effect animated",
128+
});
129+
```
130+
131+
Or via HTML:
132+
133+
```html
134+
<div data-depth="5" data-depth-add-class="class1 class2 class3">Multi-styled text</div>
135+
```
136+
137+
### Advanced Styling Examples
138+
139+
```css
140+
/* Neon glow effect */
141+
.neon-glow {
142+
color: #00ffff;
143+
text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff;
144+
}
145+
146+
/* Metallic gradient */
147+
.metallic {
148+
background: linear-gradient(90deg, #c0c0c0, #e8e8e8, #c0c0c0);
149+
-webkit-background-clip: text;
150+
-webkit-text-fill-color: transparent;
151+
}
152+
153+
/* Rainbow animation */
154+
@keyframes rainbow {
155+
0%,
156+
100% {
157+
color: #ff0000;
158+
}
159+
16% {
160+
color: #ff7f00;
161+
}
162+
33% {
163+
color: #ffff00;
164+
}
165+
50% {
166+
color: #00ff00;
167+
}
168+
66% {
169+
color: #0000ff;
170+
}
171+
83% {
172+
color: #8b00ff;
173+
}
174+
}
175+
176+
.rainbow-text {
177+
animation: rainbow 3s linear infinite;
178+
}
179+
```
180+
181+
---
182+
97183
## 🌐 Automatic Initialization
98184

99185
If you want DepthText to automatically enhance all matching elements:
@@ -137,6 +223,15 @@ You can style them globally:
137223
}
138224
```
139225

226+
With the `addClass` option, you can target specific instances:
227+
228+
```css
229+
.depthtext-layer.my-style {
230+
color: #ff6b6b;
231+
font-weight: bold;
232+
}
233+
```
234+
140235
---
141236

142237
## 📦 Browser Usage (no bundler)
@@ -171,6 +266,7 @@ export default function DepthComponent() {
171266
layers: 10,
172267
depth: "1rem",
173268
event: "pointer",
269+
addClass: "gradient-effect", // Custom styling
174270
});
175271

176272
// Cleanup on unmount
@@ -196,6 +292,7 @@ export default function DepthComponent() {
196292
dt = new DepthTextInstance(textRef.value, {
197293
layers: 10,
198294
event: "pointer",
295+
addClass: "custom-style",
199296
});
200297
}
201298
});
@@ -228,6 +325,7 @@ export class DepthTextComponent implements AfterViewInit, OnDestroy {
228325
this.dt = new DepthTextInstance(this.textRef.nativeElement, {
229326
layers: 10,
230327
event: "pointer",
328+
addClass: "angular-depth-style",
231329
});
232330
}
233331

@@ -252,7 +350,7 @@ DepthText works with various content types:
252350
### Example with mixed content:
253351

254352
```html
255-
<h1 class="depthtext" data-depth="5" data-depth-event="pointer">
353+
<h1 class="depthtext" data-depth="5" data-depth-event="pointer" data-depth-add-class="colorful">
256354
Hello World! 🚀
257355
<svg width="30" height="30"><circle cx="15" cy="15" r="10" fill="blue" /></svg>
258356
<img src="logo.png" width="40" alt="Logo" />
@@ -265,7 +363,7 @@ Images should be loaded before initialization for best results.
265363
Very large images may impact performance.
266364
External SVGs (<img src="icon.svg">) work like regular images.
267365

268-
## 🐛 Known Issues & Notes
366+
## 🛠 Known Issues & Notes
269367

270368
- DepthText uses CSS transforms; parent elements must not flatten 3D contexts.
271369
- Avoid nested DepthText unless you understand `transform-style: preserve-3d`.
@@ -283,7 +381,7 @@ If you add a major feature, please include documentation updates.
283381

284382
## 📄 License
285383

286-
MIT License free to use in commercial and open-source projects.
384+
MIT License free to use in commercial and open-source projects.
287385

288386
---
289387

demo.png

7.11 MB
Loading

0 commit comments

Comments
 (0)