blasten / turn.js

The page flip effect for HTML5
www.turnjs.com
Other
7.22k stars 2.48k forks source link

turnjs翻页功能,在我使用transform: scale(0.56389, 0.56389) 通过js对不同电脑显示器进行适配操作时出现了bug,求解决方案! #665

Open lvr1997 opened 2 years ago

lvr1997 commented 2 years ago

问题:我在通过js实现 对不同电脑显示器进行适配操作时,使用了如下代码:transform: scale(0.56389, 0.56389) 但是我发现,当我加上它之后,我点击书的右侧,他不能翻页了,

da6f0a26f12c676ed2c6403bbd0b538

当我将这段样式 从开发者模式中注销掉时,就恢复正常了。所以我现在搞不清楚,是什么原因引起的这一现象?求解决方案 1643248697(1)

如下 是我的相关代码:

//页面加载时执行
$(function() {
    calcRate()
    window.addEventListener('resize', resize)
})
//自适应translate(-50%, -50%)
function calcRate() {
    const appRef = document.getElementById("canvas")
    if(!appRef) return
    const currentRate = parseFloat((window.innerWidth / window.innerHeight).toFixed(5))
    if (appRef) {
       if (currentRate > baseProportion) {
         scale.width = ((window.innerHeight * baseProportion) / baseWidth).toFixed(5)
         scale.height = (window.innerHeight / baseHeight).toFixed(5)
         appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`
       } else {
         scale.height = ((window.innerWidth / baseProportion) / baseHeight).toFixed(5)
         scale.width = (window.innerWidth / baseWidth).toFixed(5)
         appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`
       }
    }
}

function resize () {
    clearTimeout(drawTiming)
    drawTiming = setTimeout(() => {
      this.calcRate()
    }, 200)
  }
hyf-hub commented 1 year ago

你可以使用 turn4 其中的size方法可以达到该效果

hyf-hub commented 1 year ago

你可以使用 turn4 其中的size方法可以达到该效果

https://github.com/blasten/Turn.js-4th-release

asd8855 commented 1 year ago

@hyf-hub 移动端旋转90度后,翻页位置错乱,这个该怎么解决,请求帮助

flm995942878 commented 9 months ago

我最近刚遇到类似问题..... 页面缩放后需要计算偏移量。在翻页这里,需要将原来的e.pageX和e.pageY除以缩放量 即turn.js中 e.pageX/zoom ,e.pageY/zoom