Skip to content

在ios上调用setProgress和start方法不起作用,只有repeatcount是loop时动画才会播放,在安卓上时正常的,希望作者能修复这个bug #104

@xingyufeifan

Description

@xingyufeifan

class _PagTabItemState extends State {
final GlobalKey _pagKey = GlobalKey();

@OverRide
void initState() {
super.initState();
}

@OverRide
void didUpdateWidget(PagTabItem oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.isSelected != oldWidget.isSelected) {
_handleAnimation();
}
}

void _handleAnimation() {
if (widget.isLoop) return;
final state = _pagKey.currentState;
if (state == null) return;

if (widget.isSelected) {
  state.setProgress(0);
  state.start();
} else {
  state.stop();
  state.setProgress(0);
}

}

void _onPagInit() {
if (widget.isSelected && !widget.isLoop) {
final state = _pagKey.currentState;
state?.setProgress(1);
}
}

@OverRide
Widget build(BuildContext context) {
return GestureDetector(
onTap: widget.onTap,
behavior: HitTestBehavior.opaque,
child: SizedBox(
width: widget.width,
height: widget.height,
child: IgnorePointer(
child: PAGView.asset(
widget.assetPath,
key: _pagKey,
width: widget.width,
height: widget.height,
repeatCount:
widget.isLoop
? PAGView.REPEAT_COUNT_LOOP
: PAGView.REPEAT_COUNT_DEFAULT,
initProgress: 0,
autoPlay: widget.isLoop,
onInit: _onPagInit,
),
),
),
);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions