Skip to content

Commit c669543

Browse files
committed
AI: scratch proposal for attach
1 parent c17aac0 commit c669543

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Attach Behavior - Agreed Changes
2+
3+
## Critical Missing Features
4+
5+
### 1. Scroll Container Detection
6+
- [x] CSS anchors escape overflow containers - no container detection needed
7+
- [ ] Fix `isInView()` to check viewport bounds only, not clipping parent
8+
- [ ] Change from `$el.isInView({ fully: true })` to `$el.intersects($(window), { fully: true })`
9+
10+
### 2. Mutation Observer Implementation
11+
- [ ] Add mutation observer for style changes on self
12+
- [ ] Add mutation observer for anchor removal
13+
- [ ] Default `observeChanges: false` for minimal reactivity
14+
- [ ] Implementation:
15+
```javascript
16+
mutations: {
17+
'attributes[style]': ({ self }) => self.reposition(),
18+
'remove {to}': ({ self }) => self.handleAnchorRemoved()
19+
}
20+
```
21+
22+
### 3. Destruction Cleanup
23+
- [ ] Remove `anchor-name` CSS property from anchor element
24+
- [ ] Skip inline style removal to avoid tampering with user styles
25+
- [ ] Avoid reflow sources in destroy method
26+
- [ ] Store original parent if `moveElement` was used (for potential restoration)
27+
28+
### 4. Arrow Distance Calculation
29+
- [ ] Default: arrow doesn't add to distance (for tight fits)
30+
- [ ] Add optional `arrowAddsDistance: boolean` setting
31+
- [ ] Handle corner positions with diagonal offset
32+
- [ ] Consider using `--arrow-distance-corner` CSS variable for corner cases
33+
34+
### 5. Visibility/State Management
35+
- [ ] Implement `lastResort` positioning when no positions fit
36+
- [ ] Use `alwaysShow` to control whether to position when no valid position exists
37+
- [ ] Logic:
38+
- If no positions fit AND `alwaysShow: true` → use `lastResort` position
39+
- If no positions fit AND `alwaysShow: false` → leave element unchanged
40+
41+
### 6. Fixed Issues
42+
- [x] Typo: `setting.position``settings.position` (line 279)
43+
44+
### 7. Event Integration
45+
- [ ] Listen to `transition:ended` in addition to `transition:started`
46+
- [ ] Dispatch custom events: `attach:repositioned`, `attach:fallback`, etc.
47+
- [ ] Only reposition when visible (current implementation correct)
48+
49+
### 8. Re-attachment Logic
50+
- [x] Settings updates work via reinit
51+
- [x] Multiple attachments already work (unique anchor names per instance)
52+
- [ ] Add `changeAnchor(newSelector)` method for switching anchors
53+
- [ ] Track original anchor selector for potential restoration
54+
55+
## Implementation Notes
56+
57+
- Transition events handle most common repositioning cases
58+
- Mutation observers should be minimal and opt-in
59+
- CSS anchor positioning fundamentally changes scroll container behavior
60+
- Position checking logic needs viewport-only bounds due to anchor escaping

0 commit comments

Comments
 (0)