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

3x高清方案在 iPhone Plus 系列显示的问题 #683

Closed
u0x01 opened this issue Dec 27, 2016 · 3 comments
Closed

3x高清方案在 iPhone Plus 系列显示的问题 #683

u0x01 opened this issue Dec 27, 2016 · 3 comments

Comments

@u0x01
Copy link

u0x01 commented Dec 27, 2016

  • antd-mobile 版本:0.9.13
  • 浏览器 (或标明是 react-native) 及其版本:iOS Safari / Chrome
  • 运行环境及其版本:

我参照 https://github.com/ant-design/ant-design-mobile/wiki/HD

!function(e){function t(a){if(i[a])return i[a].exports;var n=i[a]={exports:{},id:a,loaded:!1};return e[a].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var i={};return t.m=e,t.c=i,t.p="",t(0)}([function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=window;t["default"]=i.flex=function(e,t){var a=e||100,n=t||1,r=i.document,o=navigator.userAgent,d=o.match(/Android[\S\s]+AppleWebkit\/(\d{3})/i),l=o.match(/U3\/((\d+|\.){5,})/i),c=l&&parseInt(l[1].split(".").join(""),10)>=80,p=navigator.appVersion.match(/(iphone|ipad|ipod)/gi),s=i.devicePixelRatio||1;p||d&&d[1]>534||c||(s=1);var u=1/s,m=r.querySelector('meta[name="viewport"]');m||(m=r.createElement("meta"),m.setAttribute("name","viewport"),r.head.appendChild(m)),m.setAttribute("content","width=device-width,user-scalable=no,initial-scale="+u+",maximum-scale="+u+",minimum-scale="+u),r.documentElement.style.fontSize=a/2*s*n+"px"},e.exports=t["default"]}]);
flex(100, 1);

设置 Viewport,在 iPhone 7 Plus 上确实实现了 0.33333 这样的比例,但是浏览器似乎是按照 2x 进行渲染的,于是出现了下面的效果:

image

如果scale设置为 0.5 则正常,相关的讨论可以参见:amfe/lib-flexible#32

因此应该加上这个判断:

if (isIos && dpr == 3 ) {
  // 如果为 iOS, 按 2x 处理,dpr 设为 2;
  dpr = 2;
}
@silentcloud
Copy link
Contributor

silentcloud commented Dec 28, 2016

@warmhug
Copy link
Contributor

warmhug commented Jan 3, 2017

antd-mobile 的高清脚本,和 https://github.com/amfe/lib-flexible/blob/afd83fad831e43d759c24fe8fe9bdd7ca6acefee/src/flexible.js#L69 这里的不太一样,比如这段
image
会使得同为 3x 屏的不同设备点数的设备,会计算出不同的结果,设置不同的 html fontSize 作为 rem 基准。在 6plus / 7plus / 3x安卓设备上的结果可能都不同。但 antd-mobile 脚本计算出的结果应该是都一样。 不同做法、感觉各有优劣。

@warmhug warmhug closed this as completed Jan 3, 2017
@wangcongyi
Copy link

@warmhug 最近的项目上 正好两种方案都使用了下
antd-mobile的方案 在iphone5 和iphone6上都 把基准值 设置为100px (还是我要另外写配置?)
所以我觉得flexible的方案比较好

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

4 participants