refa: danmaku & feat: scroll fixed velocity (#1791)

This commit is contained in:
My-Responsitories
2025-12-29 21:03:24 +08:00
committed by GitHub
parent 0a40d11133
commit 49b7ea14c3
15 changed files with 721 additions and 770 deletions

View File

@@ -1200,17 +1200,21 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
final ctr = plPlayerController.danmakuController;
if (ctr != null) {
final pos = details.localPosition;
final item = ctr.findSingleDanmaku(pos);
if (item == null) {
final res = ctr.findSingleDanmaku(pos);
if (res != null) {
final (dy, item) = res;
if (item != _suspendedDm) {
_suspendedDm?.suspend = false;
if (item.content.extra == null) {
_dmOffset.value = null;
return;
}
_suspendedDm = item..suspend = true;
this.dy = dy;
}
} else {
_suspendedDm?.suspend = false;
_dmOffset.value = null;
} else if (item != _suspendedDm) {
_suspendedDm?.suspend = false;
if (item.content.extra == null) {
_dmOffset.value = null;
return;
}
_suspendedDm = item..suspend = true;
}
}
}
@@ -2269,6 +2273,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
static const _actionItemHeight = 35.0 - _triangleHeight;
DanmakuItem<DanmakuExtra>? _suspendedDm;
double dy = 0;
late final Rxn<Offset> _dmOffset = Rxn<Offset>();
void _removeDmAction() {
@@ -2327,9 +2332,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
final overlayWidth = _actionItemWidth * (seekOffset == null ? 3 : 4);
final dy = item.content.type == DanmakuItemType.bottom
? maxHeight - item.yPosition - item.height
: item.yPosition;
final top = dy + item.height + _triangleHeight + 2;
final realLeft = dx + overlayWidth / 2;