Double click to cycle size
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
		
					parent
					
						
							
								4a90eb341f
							
						
					
				
			
			
				commit
				
					
						52ed76a02f
					
				
			
		
					 1 changed files with 13 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -257,6 +257,11 @@ export function NewVideoGrid<T>({
 | 
			
		|||
      );
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const [lastTappedTileId, setLastTappedTileId] = useState<string | undefined>(
 | 
			
		||||
    undefined
 | 
			
		||||
  );
 | 
			
		||||
  const [lastTapTime, setLastTapTime] = useState<number>(0);
 | 
			
		||||
 | 
			
		||||
  // Callback for useDrag. We could call useDrag here, but the default
 | 
			
		||||
  // pattern of spreading {...bind()} across the children to bind the gesture
 | 
			
		||||
  // ends up breaking memoization and ruining this component's performance.
 | 
			
		||||
| 
						 | 
				
			
			@ -272,7 +277,14 @@ export function NewVideoGrid<T>({
 | 
			
		|||
    }: Parameters<Handler<"drag", EventTypes["drag"]>>[0]
 | 
			
		||||
  ) => {
 | 
			
		||||
    if (tap) {
 | 
			
		||||
      const now = Date.now();
 | 
			
		||||
 | 
			
		||||
      if (tileId === lastTappedTileId && now - lastTapTime < 500) {
 | 
			
		||||
        toggleFocus?.(items.find((i) => i.id === tileId)!);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      setLastTappedTileId(tileId);
 | 
			
		||||
      setLastTapTime(now);
 | 
			
		||||
    } else {
 | 
			
		||||
      const tileController = springRef.current.find(
 | 
			
		||||
        (c) => (c.item as Tile<T>).item.id === tileId
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue