Commit f6d9822
Fix erratic mouse behavior in the swipe (slider) compare view
The before/after slider had two classic pointer bugs:
- The screenshots are normal <img> elements, draggable by default, and
pointerdown never called preventDefault. Mousedown-then-move started a
native image drag instead of moving the divider.
- That native drag fires pointercancel, not pointerup, and only pointerup
was handled — so `dragging` never reset and the divider then tracked the
cursor on plain hover with no button held.
Apply the standard guards used by image-comparison sliders:
- preventDefault on pointerdown; respond to the primary button only.
- End the drag on pointerup AND pointercancel/lostpointercapture, and
release the pointer capture, so an interrupted gesture can't get stuck.
- Make the images non-draggable and non-interactive (draggable="false",
pointer-events:none, user-select/-webkit-user-drag:none) so the stage is
always the pointer target and can't be hijacked by a native image drag.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 411681d commit f6d9822
2 files changed
Lines changed: 38 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1133 | 1133 | | |
1134 | 1134 | | |
1135 | 1135 | | |
1136 | | - | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1137 | 1143 | | |
1138 | 1144 | | |
1139 | 1145 | | |
| |||
1158 | 1164 | | |
1159 | 1165 | | |
1160 | 1166 | | |
1161 | | - | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
1162 | 1172 | | |
1163 | 1173 | | |
1164 | 1174 | | |
| |||
1168 | 1178 | | |
1169 | 1179 | | |
1170 | 1180 | | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
1171 | 1189 | | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1172 | 1198 | | |
1173 | 1199 | | |
1174 | 1200 | | |
| |||
1178 | 1204 | | |
1179 | 1205 | | |
1180 | 1206 | | |
1181 | | - | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
1182 | 1212 | | |
1183 | 1213 | | |
1184 | 1214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
382 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
383 | 387 | | |
384 | 388 | | |
385 | 389 | | |
| |||
0 commit comments