Web platform for sharing free image data for ML and research

Homepage: https://datasets.roundabout-host.com

Fix crash in touch function

by roundabout, Friday, 31 January 2025, 11:40:16 (1738323616), pushed by roundabout, Friday, 31 January 2025, 11:40:18 (1738323618)

Author identity: vlad <vlad.muntoiu@gmail.com>

20e6503b6729c68185b2c7c8bdfd6ec585ddc4dd

static/picture-annotation.py

@@ -831,7 +831,7 @@ def on_touch_start(event):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    last_touch_distance = calculate_distance(event.touches)
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def on_touch_move(event):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            global translate_x, translate_y, scale, last_touch_positions, last_touch_distance
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            global translate_x, translate_y, scale, last_touch_positions, last_touch_distance, scale_exponent
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                if event.touches.length == 2:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    event.preventDefault()
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -847,6 +847,8 @@ def on_touch_move(event):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    if abs(current_distance - last_touch_distance) > 16:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        zoom_factor = current_distance / last_touch_distance
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        new_scale = max(0.0625, min(64, scale * zoom_factor))
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                else:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    new_scale = scale
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    # Finger midpoint.
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    midpoint_x = (current_positions[0][0] + current_positions[1][0]) / 2