<script>
  import { browser } from '$app/env';
  import { maxSize } from '$lib/config';

  export let x;
  export let y;

  const kSensorSize = 2;

  let left;
  let right;
  let top;
  let bottom;

  let timer;
  const fetchItems = function fetchItems( left, top, right, bottom ) {
    clearTimeout(timer);
		timer = setTimeout(() => {
      console.log('fetching', left, top, right, bottom);
		}, 50);
  }

  $: {
    if (browser) {
      left = x - window.screen.width * kSensorSize;
      top = y - window.screen.height * kSensorSize;
      right = x + window.screen.width * kSensorSize;
      bottom = y + window.screen.height * kSensorSize;

      fetchItems(left, top, right, bottom);
    }
  }

</script>
