当前位置:网站首页>Wechat applet pictures are scaled according to the screen scale
Wechat applet pictures are scaled according to the screen scale
2022-07-28 02:05:00 【Best friend sunshine】
// The picture is scaled according to the screen scale
imageUtil(e) {
let self = this,
imageSize = {
},
originalWidth = e.detail.width,// The original width of the picture
originalHeight = e.detail.height,// The original height of the picture
originalScale = originalHeight/originalWidth;// Picture aspect ratio
let windowWidth = self.data.phoneInfo.windowWidth,
windowHeight = self.data.phoneInfo.windowHeight,
windowscale = windowHeight/windowWidth;// Screen aspect ratio
if(originalScale < windowscale){
// The picture aspect ratio is smaller than the screen aspect ratio
// The zoom width of the picture is the screen width
imageSize.imageWidth = windowWidth;
imageSize.imageHeight = (windowWidth * originalHeight) / originalWidth;
}else{
// The picture aspect ratio is greater than the screen aspect ratio
// The zoom height of the picture is the screen height
imageSize.imageHeight = windowHeight;
imageSize.imageWidth = (windowHeight * originalWidth) / originalHeight;
};
return imageSize;
},
边栏推荐
- Starfish OS X metabell strategic cooperation, metauniverse business ecosystem further
- Domain Driven Design -- Terminology
- Hcip 13th day notes
- Unity universal red dot system
- Netease cloud copywriting
- day7
- GBase 8c 通用文件访问函数
- A happy old age
- Software testing interview question: what do you think is the key to good test case design?
- 简单为美-编程思路
猜你喜欢
![Likeshop takeout ordering system [100% open source, no encryption]](/img/e6/a73aa817b5b30339d755aa53708072.png)
Likeshop takeout ordering system [100% open source, no encryption]

Graph theory analysis of white matter brain function network: neural markers for classification and prediction of depression

Redis设计规范

Embedded classic communication protocol

Lambda expressions and stream streams

What is method and methodology: understand the underlying logic of self-improvement

ArcGIS:加载历史遥感影像

Forget the root password

二叉树的遍历和性质

The storage cost is reduced by 80%. How does the cost management of youzan data middle office do?
随机推荐
Causes and solutions of JS digital accuracy loss
Gbase 8C transaction ID and snapshot (III)
Likeshop takeout ordering system [100% open source, no encryption]
HyperMesh circular array - plug in
如何评估研发人员效能?软件工程师报告帮你看见每个人的贡献
Interviewer: are you sure redis is a single threaded process?
轻量版项目管理系统
##ELK日志分析系统搭建##
软件测试面试题:测试计划工作的目的是什么?测试计划工作的内容都包括什么?其中哪些是最重要的?
Software testing interview question: why should we carry out testing in a team?
The story of amen
对话Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
Vxe Table/Grid 单元格分组合并
Completely delete MySQL in Linux system
GBase 8c 备份控制函数(三)
测试/开发程序员的级别“陷阱“,级别不是衡量单维度的能力......
网易云仿写
Real time data warehouse: meituan's real-time data warehouse construction practice
[interview: concurrent article 28:volatile] orderliness
数字经济才是未来经济发展的核心