Last active
May 27, 2018 04:39
-
-
Save JetLua/6a4984dbdf96b1658cd7e05fe4541efa to your computer and use it in GitHub Desktop.
pixi 旋转画布后的事件处理兼容(https://github.com/pixijs/pixi.js/blob/dev/src/interaction/InteractionManager.js#L955)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PIXI.interaction.InteractionManager.prototype.mapPositionToPoint = function(point, x, y) { | |
let rect | |
// IE 11 fix | |
if (!this.interactionDOMElement.parentElement) { | |
rect = {x: 0, y: 0, width: 0, height: 0} | |
} else { | |
rect = this.interactionDOMElement.getBoundingClientRect() | |
} | |
const resolutionMultiplier = navigator.isCocoonJS ? this.resolution : (1.0 / this.resolution) | |
/* | |
* 特殊处理: 强制横屏情况 | |
*/ | |
if (window.orientation === 0) { | |
point.x = (y - rect.top) * (this.interactionDOMElement.width / rect.height) * resolutionMultiplier | |
point.y = (1 - (x - rect.left) / rect.width) * this.interactionDOMElement.height * resolutionMultiplier | |
} else { | |
point.x = ((x - rect.left) * (this.interactionDOMElement.width / rect.width)) * resolutionMultiplier | |
point.y = ((y - rect.top) * (this.interactionDOMElement.height / rect.height)) * resolutionMultiplier | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment