Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

页面滚动到非顶部时,刮刮乐失效的问题,解决方案如下 #9

Open
Marszed opened this issue Oct 16, 2017 · 0 comments

Comments

@Marszed
Copy link

Marszed commented Oct 16, 2017

winTcanvasXY: function (canvas, x, y) {
var cC = canvas.getBoundingClientRect();

    // author Marszed https://github.com/Marszed
    // 解决页面滚动,刮刮乐失效的问题
    // FIX chrome对document.documentElement.scrollHeight&document.documentElement.scrollTop是不能识别的,而firefox和IE11不能识别document.body.scrollHeight&document.body.scrollTop
    // 需要减去滚动距离
    var scrollTop = document.body.scrollTop==0?document.documentElement.scrollTop:document.body.scrollTop;

    return {
        x: x - cC.left,
        y: y - cC.top - scrollTop
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant