mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +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.zoomHandler();
|
||||
|
||||
// translateCanvas starts a requestAnimationFrame loop
|
||||
this.translateCanvas();
|
||||
|
||||
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 = () => {
|
||||
this.translateCanvas();
|
||||
// this.translateCanvas();
|
||||
}
|
||||
|
||||
private translateCanvas() {
|
||||
const scrollPositionX = window.scrollX - this.overflowLeftSize;
|
||||
const scrollPositionY = window.scrollY - this.overflowTopSize;
|
||||
this.canvas.style.transform =`translate(${scrollPositionX}px,${scrollPositionY}px)`;
|
||||
requestAnimationFrame(() => this.translateCanvas());
|
||||
}
|
||||
|
||||
private zoomHandler = () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user