Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Commit de6c577

Browse files
committed
Spam protection for swiping
1 parent 8a94fdd commit de6c577

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/animate.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def __init__(self, canvas: tk.Canvas):
133133

134134
def start(self):
135135
while self._motions:
136+
print(self._motions)
136137
complete = self.run(self._motions.copy())
137138
self._motions -= complete
138139
time.sleep(1/self.fps)
@@ -157,6 +158,10 @@ def add_motion(self, id: int, end: Coord, **kwargs):
157158
def clear(self):
158159
self._motions.clear()
159160

161+
@property
162+
def running(self):
163+
return bool(self._motions)
164+
160165

161166
@dataclass
162167
class Motion:

src/front.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class Front(widget.PrimaryFrame):
2424
_last = None
2525

2626
def __next(self, direction: Direction = None):
27+
if self.window.active:
28+
return
2729
if self.cache.ready():
2830
data: dict = self.cache.next()
2931
image = process_image(

src/view.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def get_distance(self, direction: Direction):
105105
else:
106106
raise NotImplementedError
107107

108+
@property
109+
def active(self):
110+
return self.animater.running
111+
108112
@property
109113
def origin(self):
110114
return Coord(self.canvasx(0), self.canvasy(0))

0 commit comments

Comments
 (0)