javascript - Scandit Websdk Javascript 设置方向
问题描述
我正在使用 scandit 进行我的 webapp 二维码扫描。一切正常,但我只是停留在如何设置 scandit-barcode-picker 的大小。我希望它在横向模式下占手机屏幕的一半。我找不到任何有关设置方向的文档。这是我初始化的方式。
HTML:
<div id="scandit-barcode-picker" style="max-height: 300px !important;"></div>
Javascript:
const licenseKey = SCANDIT_LICENSE;
let decoder;
ScanditSDK.configure(licenseKey, {
engineLocation: string = "https://cdn.jsdelivr.net/npm/scandit-sdk/build"
});
ScanditSDK.BarcodePicker.create(document.getElementById("scandit-barcode-picker"), {
playSoundOnScan: true,
vibrateOnScan: true,
}).then(function (barcodePicker) {
decoder = barcodePicker;
var scanSettings = new ScanditSDK.ScanSettings({
enabledSymbologies: ["code128", "code39"],
codeDuplicateFilter: 1000,
});
decoder.applyScanSettings(scanSettings);
decoder.setPlaySoundOnScanEnabled(true);
decoder.on("scan", function (scanResult) {
barcode = scanResult.barcodes.pop();
onScanned({
format: ScanditSDK.Barcode.Symbology.toHumanizedName(barcode.symbology),
code: barcode.data
});
});
decoder.resumeScanning();
});
这是采取高度但也保持纵横比。它以纵向模式显示。我想要横向模式。请问有什么帮助吗?
解决方案
免责声明:我为 Scandit 工作
WebSDK BarcodePicker 自动适应并适应给定的容器元素(在本例中为scandit-barcode-picker
div),因此您只需通过 CSS/JS 独立于库将您想要的任何样式逻辑应用于该元素。
为了实现您的目标,您可能需要类似的东西
@media screen and (orientation: landscape) {
#scandit-barcode-picker {
...
}
}
在你的风格。
推荐阅读
- php - CentOS 上的 PHP 7.4.10 错误:无法找到 gmp.h
- java - 运行可执行Jar时如何保持控制台打开?
- python - 量化的 TFLite 模型比 TF 模型提供更好的准确性
- python - 在 Gekko 中将两个函数与条件 (if) 开关结合起来
- gitlab - Gitlab 自托管企业版是免费的吗?
- git - 为什么大多数(不是全部)github 操作在 Raspberry Pi 上失败(443 连接被拒绝)?
- linux - 使用 diff -u 显示两个文件之间的差异
- glsl - GLSL-ES3(webGL2):如何从片段着色器测试扩展?
- time-complexity - 给定一个显示各种输入大小值与它们相应的运行时间值的 Excel 表,我如何确定“Big-oh”时间复杂度
- c# - C# 中返回 void 的高阶函数