Update resize method and debounce it on component
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
import { quartOut } from 'svelte/easing'
|
import { quartOut } from 'svelte/easing'
|
||||||
import { Globe, type Marker } from '$modules/globe2'
|
import { Globe, type Marker } from '$modules/globe2'
|
||||||
import { getRandomItem } from '$utils/functions'
|
import { getRandomItem, debounce } from '$utils/functions'
|
||||||
// Components
|
// Components
|
||||||
import Image from '$components/atoms/Image.svelte'
|
import Image from '$components/atoms/Image.svelte'
|
||||||
|
|
||||||
@@ -90,9 +90,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resize
|
// Resize
|
||||||
const resize = () => {
|
const resize = debounce(() => {
|
||||||
globe.resize()
|
globe.resize()
|
||||||
}
|
}, 100)
|
||||||
|
|
||||||
// Destroy
|
// Destroy
|
||||||
const destroy = () => {
|
const destroy = () => {
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ export class Globe {
|
|||||||
*/
|
*/
|
||||||
resize () {
|
resize () {
|
||||||
// this.renderer.setSize(window.innerWidth, window.innerHeight)
|
// this.renderer.setSize(window.innerWidth, window.innerHeight)
|
||||||
|
this.width = this.el.offsetWidth
|
||||||
|
this.height = this.el.offsetHeight
|
||||||
this.renderer.setSize(this.width, this.height)
|
this.renderer.setSize(this.width, this.height)
|
||||||
this.camera.perspective({
|
this.camera.perspective({
|
||||||
aspect: this.gl.canvas.width / this.gl.canvas.height
|
aspect: this.gl.canvas.width / this.gl.canvas.height
|
||||||
|
|||||||
Reference in New Issue
Block a user