mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Translate is done each frame through requestAnimationFrame.
This commit is contained in:
parent
6c0b1b8c2c
commit
034c6266e8
@ -637,6 +637,8 @@ class SpineWebComponentOverlay extends HTMLElement {
|
|||||||
|
|
||||||
this.updateCanvasSize();
|
this.updateCanvasSize();
|
||||||
this.zoomHandler();
|
this.zoomHandler();
|
||||||
|
|
||||||
|
// translateCanvas starts a requestAnimationFrame loop
|
||||||
this.translateCanvas();
|
this.translateCanvas();
|
||||||
|
|
||||||
this.overflowLeftSize = this.overflowLeft * document.documentElement.clientWidth;
|
this.overflowLeftSize = this.overflowLeft * document.documentElement.clientWidth;
|
||||||
@ -955,14 +957,17 @@ class SpineWebComponentOverlay extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// right now, we scroll the canvas each frame, that makes scrolling on mobile waaay more smoother
|
||||||
|
// this is way scroll handler do nothing
|
||||||
private scrollHandler = () => {
|
private scrollHandler = () => {
|
||||||
this.translateCanvas();
|
// this.translateCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
private translateCanvas() {
|
private translateCanvas() {
|
||||||
const scrollPositionX = window.scrollX - this.overflowLeftSize;
|
const scrollPositionX = window.scrollX - this.overflowLeftSize;
|
||||||
const scrollPositionY = window.scrollY - this.overflowTopSize;
|
const scrollPositionY = window.scrollY - this.overflowTopSize;
|
||||||
this.canvas.style.transform =`translate(${scrollPositionX}px,${scrollPositionY}px)`;
|
this.canvas.style.transform =`translate(${scrollPositionX}px,${scrollPositionY}px)`;
|
||||||
|
requestAnimationFrame(() => this.translateCanvas());
|
||||||
}
|
}
|
||||||
|
|
||||||
private zoomHandler = () => {
|
private zoomHandler = () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user