Skip to content

Commit a57108a

Browse files
committed
Refactor resize system to use edge/corner zones
Replace single bottom-right resizer with 8 invisible resize zones along all edges and corners (n, s, e, w, ne, nw, se, sw). Window can now be resized from any direction. Changes: - Add ResizeDirection type and resizeDirection state - Add startX/startY to DragState for proper delta calculations - Update DEFAULT_WINDOW_TEMPLATE with 8 resize zone divs - Update DEFAULT_STYLES to position resize zones and use flexbox layout - Refactor initDragAndResize() to setup handlers for all directions - Add handleDirectionalResize() method for directional resize logic - Update updateDockedResizerCursor() to show/hide zones based on dock state - Update documentation and demo to reflect new resize behavior
1 parent eaa2611 commit a57108a

File tree

7 files changed

+203
-140
lines changed

7 files changed

+203
-140
lines changed

demo/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ <h1>service-injector Demo</h1>
232232

233233
<div class="note">
234234
<strong>Tip:</strong> After selecting options, look for the floating tab on the edge of the screen.
235-
Click the tab to open the window. You can drag the window header and resize from the bottom-right corner
235+
Click the tab to open the window. You can drag the window header and resize from any edge or corner
236236
(if those features are enabled). When dockable is enabled, drag the window to any screen edge to dock it
237237
(pushes page content aside). Double-click the header or drag away to undock.
238238
</div>
@@ -279,8 +279,7 @@ <h1>service-injector Demo</h1>
279279
"#%prefix%-header { background: #16213e; color: #eee; }" +
280280
"#%prefix%-window { background: #1a1a2e; border: 1px solid #444; }" +
281281
"#%prefix%-body { border-color: #444; }" +
282-
"#%prefix%-header a { color: #eee; }" +
283-
"#%prefix%-resizer { border-color: #666; }"
282+
"#%prefix%-header a { color: #eee; }"
284283
},
285284
minimal: {
286285
tabTemplate: "<a onclick='return %prefix%ToggleWindow();' href='%url%'>☰</a>",

docs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
┌─────────────────────────────────────┐
99
│ Client's Website │
1010
│ │
11-
─────────┐ │
12-
Your │ ← Floating tab │
13-
Service │ (click to open) │
14-
─────────┘ │
11+
│─────────┐
12+
│ Your │ ← Floating tab
13+
│ Service │ (click to open)
14+
│─────────┘
1515
│ │
1616
└─────────────────────────────────────┘
1717

docs/customization.md

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,11 @@ These are the DOM elements created by service-injector:
136136
├── #si-tab (floating tab button)
137137
│ └── [your tab template content]
138138
└── #si-window (popup window)
139-
└── #si-inner
140-
├── #si-header (draggable header)
141-
├── #si-body
142-
│ └── #si-iframe (your content)
143-
└── #si-footer
144-
└── #si-resizer (resize handle)
139+
├── #si-inner
140+
│ ├── #si-header (draggable header)
141+
│ └── #si-body
142+
│ └── #si-iframe (your content)
143+
└── resize zones (invisible, on all edges and corners)
145144
```
146145

147146
<!-- TODO: Add annotated screenshot showing element IDs -->
@@ -153,10 +152,10 @@ These are the DOM elements created by service-injector:
153152
| `#si-header` | Draggable header bar | Background, height, cursor |
154153
| `#si-body` | Content area | Border, padding |
155154
| `#si-iframe` | Embedded content | Width, height (auto-managed) |
156-
| `#si-footer` | Footer area | Usually minimal styling |
157-
| `#si-resizer` | Resize handle | Cursor, size |
158155
| `#si-shadow` | Animation placeholder | Background color |
159156

157+
**Resize zones:** The window can be resized from all edges and corners. These zones are invisible (6px wide) and positioned along each edge.
158+
160159
**Note:** Replace `si` with your custom prefix if using one.
161160

162161
---
@@ -181,10 +180,8 @@ For reference when creating custom templates:
181180
<div id='%prefix%-body'>
182181
<iframe id='%prefix%-iframe'></iframe>
183182
</div>
184-
<div id='%prefix%-footer'>
185-
<div id='%prefix%-resizer'></div>
186-
</div>
187183
</div>
184+
<!-- Resize zones are automatically added for all edges and corners -->
188185
```
189186

190187
### Default Styles
@@ -205,41 +202,31 @@ For reference when creating custom templates:
205202
height: 100%;
206203
width: 100%;
207204
position: relative;
205+
display: flex;
206+
flex-direction: column;
208207
}
209208
#si-header {
210209
height: 1.5em;
211210
background: #aaa;
212211
text-align: right;
213212
padding: 0 0.5em;
214213
cursor: move;
214+
flex-shrink: 0;
215215
}
216216
#si-body {
217217
border: 1px solid #aaa;
218-
bottom: 0;
218+
flex: 1;
219+
overflow: hidden;
219220
}
220221
#si-iframe {
221222
border: 0;
222-
}
223-
#si-footer {
224-
position: absolute;
225-
bottom: 0;
226-
left: 0;
227-
right: 0;
228-
}
229-
#si-resizer {
230-
width: 10px;
231-
height: 10px;
232-
float: right;
233-
position: relative;
234-
right: -2px;
235-
bottom: -2px;
236-
border-right: 3px solid black;
237-
border-bottom: 3px solid black;
238-
cursor: se-resize;
223+
width: 100%;
224+
height: 100%;
239225
}
240226
#si-shadow {
241227
background: grey;
242228
}
229+
/* Resize zones are positioned along edges and corners */
243230
```
244231

245232
---
@@ -307,9 +294,7 @@ For reference when creating custom templates:
307294
#si-body {
308295
border-color: #444;
309296
}
310-
#si-resizer {
311-
border-color: #666;
312-
}
297+
313298
`
314299
};
315300
</script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "service-injector",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Lightweight library for SaaS providers to embed services on client websites as a floating tab/window with iframe integration",
55
"author": "OrienteerBAP",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)