Skip to content

Commit 31a07a0

Browse files
committed
update to 1.2.0
1 parent ae696f8 commit 31a07a0

6 files changed

Lines changed: 469 additions & 178 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ demo.js
2424
styles.css
2525
index copy.html
2626

27-
depthtext SAUVEGARDE.ts
27+
depthtext copy.ts

CHANGELOG.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,78 @@
22

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

5+
## [1.2.0] - 2025-01-24
6+
7+
### Added
8+
9+
- **New `layerClassMap` option**: Map custom CSS classes to individual layers by index
10+
- Allows unique styling per layer (e.g., different colors for each depth level)
11+
- Available via JavaScript API: `layerClassMap: ["front", "middle", "back"]`
12+
- Combines with `addClass` for maximum flexibility
13+
- Example: Create rainbow gradients across depth layers
14+
- **Auto-generated layer classes**: Each layer now receives `depthtext-layer-N` class (0-indexed)
15+
- Enables precise CSS targeting: `.depthtext-layer-0`, `.depthtext-layer-1`, etc.
16+
- Works independently of `layerClassMap` for even more control
17+
- **Public `.update()` method**: Dynamically modify options after initialization
18+
- Change depth, layers, event type, etc. without recreating instance
19+
- Useful for responsive designs and interactive controls
20+
- Example: `instance.update({ depth: "2rem", event: "scroll" })`
21+
22+
### Fixed
23+
24+
- **CRITICAL: `data-depth` attribute parsing**
25+
- Fixed bug where `data-depth` value was incorrectly assigned to `engaged` option
26+
- Now correctly uses `data-depth-engaged` for enabling/disabling instances
27+
- `data-depth` now exclusively controls depth value as intended
28+
- Prevents accidental instance disabling when using numeric depth values
29+
- **Enhanced `engaged` validation**
30+
- Properly handles boolean, string boolean ("true"/"false"), and undefined values
31+
- More robust type coercion prevents unexpected behavior
32+
- **Event type validation**
33+
- Added whitelist validation for `event` option
34+
- Console warning for invalid event types with automatic fallback to "none"
35+
- Prevents silent failures from typos
36+
- **ResizeObserver memory leak**
37+
- Added destruction check in ResizeObserver callback
38+
- Prevents updates on destroyed instances
39+
- Improves cleanup and garbage collection
40+
- **Duplicate CSS classes**
41+
- Layer creation now uses Set to eliminate duplicate class names
42+
- More efficient and cleaner DOM output
43+
- **Data attribute parsing**
44+
- Now supports both camelCase and lowercase variants: `data-depth-event-rotation` and `data-depth-eventrotation`
45+
- Empty string data attributes (`data-depth=""`) now correctly treated as undefined
46+
- Improved robustness across different HTML coding styles
47+
48+
### Changed
49+
50+
- **Type safety improvements**
51+
- Removed `any` from `MaybeElement` type definition
52+
- Now strictly typed as `HTMLElement | Element | null`
53+
- Better TypeScript inference and error catching
54+
- **Destruction tracking**
55+
- Added internal `_isDestroyed` flag
56+
- Prevents double-destroy and updates on destroyed instances
57+
- More predictable lifecycle management
58+
59+
### Technical
60+
61+
- Refactored `_validateOptions()` with specialized normalizer functions
62+
- Added `normalizeEngaged()` and `normalizeEvent()` helpers
63+
- Improved options merging logic in `DepthTextify()`
64+
- Enhanced data attribute reading with `getDataAttr()` helper
65+
- Layer class application now uses Set for deduplication
66+
- Better separation of concerns in validation layer
67+
68+
### Documentation
69+
70+
- Added important notes about layer styling limitations
71+
- Documented `layerClassMap` behavior when fewer classes than layers
72+
- Updated all examples to reflect new `data-depth-engaged` attribute
73+
- Added CSS best practices for individual layer coloring
74+
75+
---
76+
577
## [1.1.0] - 2025-01-21
678

779
### Added
@@ -24,7 +96,9 @@ All notable changes to this project will be documented in this file.
2496
- Extended `DepthTextOptions` interface with `addClass` property
2597
- Updated `DEPTHTEXT_DEFAULTS` to include `addClass: ""`
2698

27-
## [1.0.0] - 2025-11-19
99+
---
100+
101+
## [1.0.0] - 2025-01-19
28102

29103
### Added
30104

0 commit comments

Comments
 (0)