Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

bug: The on_interaction_update event of the InteractiveViewer component has an error in the data returned

オープン
#6,469 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
flutter, python
領域
frontend

調査の方向性

付属の Python 再現コードと ft.InteractiveViewer on_interaction_update エントリーポイントから始め、interaction_update_interval データがどのように返されるかを追跡します。200 ミリ秒以内に 3 回のスクロールホイールイベントを発生させて動作を確認します。間隔を 0 にする必要なく、callback がそれらの累積結果を報告すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug
Duplicate Check
Describe the bug

In the ft.InteractiveViewer() component, if interaction_update_interval is set to 200 milliseconds, the returned data should include all events that occurred within that interval. For example, if I trigger three scroll wheel events within 200 milliseconds, it should return the cumulative result of those three scroll events. However, Flet actually returns the data for only one event. To get correct data, you need to set interaction_update_interval to 0, but this causes significant performance overhead.

Code sample
Code

import flet as ft
from typing import  cast


@ft.control
class BaseCanvas(ft.GestureDetector):
    max_scale: float = 3
    scale_step: float = 0.25
    min_scale: float = 0.25

    def init(self):
        self.cumulative_offset_x = self.cumulative_offset_y = 0
        self.current_scale = 1

        self.window_container_size = ()
        self.canvas_size=()
        
        
        self.scaled_canvas_size = ()
        self.scale_offset_x = 0
        self.scale_offset_y = 0

        self.canvas_container = ft.Container(
            bgcolor=ft.Colors.BLUE_100,
            content=ft.Stack(
                controls=[
                    self.module_container((50, 50)),
                    self.module_container((50, 600)),
                    self.module_container((1000, 50)),
                    self.module_container((1000, 600)),
                ],
            ),
        )

        self.content = ft.InteractiveViewer(
            expand=True,
            clip_behavior= ft.ClipBehavior.HARD_EDGE,
            content=self.canvas_container,
            on_size_change = lambda e: self.get_window_container_size(e),
            constrained = False,
            on_interaction_update=lambda e:  print(e),

        )


        self.on_hover = self.mouse_hover_event

    def module_container(self, pos):
        module = ft.Container(
            bgcolor=ft.Colors.GREEN,
            width=70,
            content=ft.Column(
                [
                    ft.Container(width=70, content=ft.Text(f"module {j}"))
                    for j in range(10)
                ]
            ),
        )

        return ft.GestureDetector(
            mouse_cursor=ft.MouseCursor.MOVE,
            drag_interval=5,
            left=pos[0],
            top=pos[1],
            content=module,
        )

    def get_window_container_size(self, e):

        self.window_container_size = (e.width, e.height)
        if not self.canvas_size or self.canvas_size<self.window_container_size:
            self.canvas_size=self.window_container_size


            self.canvas_container.width,self.canvas_container.height=self.window_container_size
            self.canvas_container=cast(ft.Container,self.canvas_container)
            self.canvas_container.update()
        print(self.window_container_size)

    def mouse_hover_event(self, e: ft.HoverEvent[ft.GestureDetector]) -> None:
        """Handle mouse hover, compute canvas coordinates"""
        if e.local_delta is None:
            return







if __name__ == "__main__":

    def main(page: ft.Page):
        canvas = BaseCanvas()
        page.add(
            ft.Container(expand=True,bgcolor=ft.Colors.AMBER, content=canvas),
        )

    ft.run(main)


To reproduce
  1. Run the code
  2. Scale to the maximum size
  3. Observe the scale data returned by the on_interaction_update event.
Expected behavior

No response

Screenshots / Videos
Captures

[Upload media here]

Operating System

Windows

Operating system details

11

Flet version

0.85

Regression

No, it isn't

Suggestions

No response

Logs
Logs
[Paste your logs here]
Additional details

No response

主要言語
Python
スター
17.4k
フォーク
728
平均マージ
1日 7時間
マージ済み PR(30日)
51

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

flet-dev/flet のほかの issue

flet-dev/flet の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。