Make it work on mobile devices
This commit is contained in:
parent
253559bfc8
commit
4495444ec9
3 changed files with 14 additions and 11 deletions
|
|
@ -78,10 +78,11 @@ export class Display {
|
|||
let currentBB = this.layout.getBoundingBox()
|
||||
let width = this.target.scrollWidth || 100
|
||||
let height = this.target.scrollHeight || 100
|
||||
const ballRadius = Math.min(document.body.clientWidth, document.body.clientHeight) * 0.06
|
||||
var toScreen = function(p) {
|
||||
var size = currentBB.topright.subtract(currentBB.bottomleft);
|
||||
var sx = p.subtract(currentBB.bottomleft).divide(size.x).x * (width - 60) + 30;
|
||||
var sy = p.subtract(currentBB.bottomleft).divide(size.y).y * (height - 60) + 30;
|
||||
var sx = p.subtract(currentBB.bottomleft).divide(size.x).x * (width - ballRadius * 2) + ballRadius;
|
||||
var sy = p.subtract(currentBB.bottomleft).divide(size.y).y * (height - ballRadius * 2) + ballRadius;
|
||||
return new Springy.Vector(sx, sy);
|
||||
};
|
||||
|
||||
|
|
@ -133,8 +134,8 @@ export class Display {
|
|||
}
|
||||
dom.className = item.data.state
|
||||
dom.style.position = 'absolute'
|
||||
dom.style.left = (target.x - 60) + 'px'
|
||||
dom.style.top = (target.y - 60) + 'px'
|
||||
dom.style.left = (target.x - ballRadius) + 'px'
|
||||
dom.style.top = (target.y - ballRadius) + 'px'
|
||||
dom.appendChild(a)
|
||||
field.appendChild(dom)
|
||||
}, undefined, undefined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue