javascript - 当 true 忽略其他所有内容时,Javascript 多个 if 停止
问题描述
我有 25 个 IF 语句,它们查看图像并根据其大小和与 Photoshop 中的文档大小(画布)相关的位置执行不同的功能。
我发现当脚本执行 if 为 true 时,它不会继续向下堆栈并执行其他 true if。
这是javascript的副产品,还是我的错误?
例如,这两个 if 都为真,但它只执行第一个。如果我再次运行该脚本,它将执行第二个 if。但我想弄清楚如何让脚本运行所有如果,即使一个是真的。
//bottom edge only off doc
if (layerSmaller && layerLeftIn && layerRightIn && layerTopIn && layerBottomOut) {
activeDocument.activeLayer.translate(0,docHeight-layerBottom+2);
var percentageChange = ((docHeight / layerHeight) * 101);
resizeBCenter(percentageChange)
}
//layer smaller horizontally and right more than 65
if (layerWidth <= docWidth && layerTopOut && layerBottomOut && layerLeftOut && layerRightIn && Rmargin >= 65) {
var percentageChange = ((docWidth / layerWidth) * 101);
resizeTLeft(percentageChange)
app.activeDocument.selection.selectAll();
align('AdCH');
align('AdCV');
app.activeDocument.selection.deselect();
}
这可以做到吗?
解决方案
推荐阅读
- java - 如何组合两个异步 webclient 调用,假设一个调用遇到异常
- nodemon - Nodemon:忽略受监视文件夹中的单个文件
- python - 根据条件将列表的元素连接到一个新列表中
- computer-vision - ArUco 标记代码中的歧义
- xamarin - 如何在 Xamarin 中实现自动登录?
- php - Xpath - 选择具有属性的元素并获取另一个属性值
- java - 如何禁用安全音量警告 SystemUI
- asp.net - 如何在 Asp.Net/VB.Net 中使用 AjaxUploader 上传视频文件时生成缩略图?
- assembly - 如何将数学随机的过程更改为在 dw 中而不是在 db 中返回我?
- c# - Asp.Net Core 2.2 身份认证