@@ -41,6 +41,7 @@ class _InteractiveViewerControlState extends State<InteractiveViewerControl>
4141 late AnimationController _animationController;
4242 Animation <Matrix4 >? _animation;
4343 Matrix4 ? _savedMatrix;
44+ int _interactionUpdateTimestamp = DateTime .now ().millisecondsSinceEpoch;
4445
4546 @override
4647 void initState () {
@@ -158,22 +159,30 @@ class _InteractiveViewerControlState extends State<InteractiveViewerControl>
158159 : null ,
159160 onInteractionUpdate: ! disabled
160161 ? (ScaleUpdateDetails details) {
161- debugPrint (
162- "InteractiveViewer ${widget .control .id } onInteractionUpdate" );
163- widget.backend.triggerControlEvent (
164- widget.control.id,
165- "interaction_update" ,
166- jsonEncode ({
167- "pc" : details.pointerCount,
168- "fp_x" : details.focalPoint.dx,
169- "fp_y" : details.focalPoint.dy,
170- "lfp_x" : details.localFocalPoint.dx,
171- "lfp_y" : details.localFocalPoint.dy,
172- "s" : details.scale,
173- "hs" : details.horizontalScale,
174- "vs" : details.verticalScale,
175- "rot" : details.rotation,
176- }));
162+ var interactionUpdateInterval =
163+ widget.control.attrInt ("interactionUpdateInterval" , 0 )! ;
164+ var now = DateTime .now ().millisecondsSinceEpoch;
165+ if (now - _interactionUpdateTimestamp >
166+ interactionUpdateInterval) {
167+ debugPrint (
168+ "InteractiveViewer ${widget .control .id } onInteractionUpdate" );
169+ _interactionUpdateTimestamp = now;
170+ widget.backend.triggerControlEvent (
171+ widget.control.id,
172+ "interaction_update" ,
173+ jsonEncode ({
174+ "pc" : details.pointerCount,
175+ "fp_x" : details.focalPoint.dx,
176+ "fp_y" : details.focalPoint.dy,
177+ "lfp_x" : details.localFocalPoint.dx,
178+ "lfp_y" : details.localFocalPoint.dy,
179+ "s" : details.scale,
180+ "hs" : details.horizontalScale,
181+ "vs" : details.verticalScale,
182+ "rot" : details.rotation,
183+ }));
184+ ;
185+ }
177186 }
178187 : null ,
179188 child: contentCtrls.isNotEmpty
0 commit comments