Fix video and select element sizes

This commit is contained in:
Knyffen 2024-10-25 13:13:00 +02:00
parent 81be549ac9
commit 59fc2e9bfd
7 changed files with 25 additions and 51 deletions

View File

@ -27,8 +27,8 @@ export interface InitOutput {
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_export_2: WebAssembly.Table;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ee002e21c3855c9: (a: number, b: number, c: number) => void;
readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hda38a12a2a1c09dc: (a: number, b: number) => void;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ee002e21c3855c9: (a: number, b: number, c: number) => void;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha7dc131e1b42f45e: (a: number, b: number, c: number) => void;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;

View File

@ -211,12 +211,12 @@ function makeMutClosure(arg0, arg1, dtor, f) {
CLOSURE_DTORS.register(real, state, state);
return real;
}
function __wbg_adapter_36(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ee002e21c3855c9(arg0, arg1, addHeapObject(arg2));
function __wbg_adapter_36(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hda38a12a2a1c09dc(arg0, arg1);
}
function __wbg_adapter_39(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hda38a12a2a1c09dc(arg0, arg1);
function __wbg_adapter_39(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ee002e21c3855c9(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_42(arg0, arg1, arg2) {
@ -275,7 +275,7 @@ function passArray8ToWasm0(arg, malloc) {
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function __wbg_adapter_205(arg0, arg1, arg2, arg3) {
function __wbg_adapter_197(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h101e073056d1eef9(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}
@ -551,20 +551,6 @@ function __wbg_get_imports() {
const ret = result;
return ret;
};
imports.wbg.__wbg_setwidth_7aa91c44601eed4e = function(arg0, arg1) {
getObject(arg0).width = arg1 >>> 0;
};
imports.wbg.__wbg_setheight_e6f800ffbc3ea28e = function(arg0, arg1) {
getObject(arg0).height = arg1 >>> 0;
};
imports.wbg.__wbg_videoWidth_5f4190ae93af0dd6 = function(arg0) {
const ret = getObject(arg0).videoWidth;
return ret;
};
imports.wbg.__wbg_videoHeight_4fb4bdd27e02263a = function(arg0) {
const ret = getObject(arg0).videoHeight;
return ret;
};
imports.wbg.__wbg_set_b3c7c6d2e5e783d6 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
getObject(arg0).set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
}, arguments) };
@ -783,7 +769,7 @@ function __wbg_get_imports() {
const a = state0.a;
state0.a = 0;
try {
return __wbg_adapter_205(a, state0.b, arg0, arg1);
return __wbg_adapter_197(a, state0.b, arg0, arg1);
} finally {
state0.a = a;
}
@ -853,16 +839,16 @@ function __wbg_get_imports() {
const ret = wasm.memory;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper199 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 33, __wbg_adapter_36);
imports.wbg.__wbindgen_closure_wrapper171 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 27, __wbg_adapter_36);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper200 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 33, __wbg_adapter_39);
imports.wbg.__wbindgen_closure_wrapper172 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 27, __wbg_adapter_39);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper1797 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 498, __wbg_adapter_42);
imports.wbg.__wbindgen_closure_wrapper1787 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 495, __wbg_adapter_42);
return addHeapObject(ret);
};

Binary file not shown.

View File

@ -8,8 +8,8 @@ export function enable_panic_debug(): void;
export function __wbindgen_malloc(a: number, b: number): number;
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
export const __wbindgen_export_2: WebAssembly.Table;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ee002e21c3855c9(a: number, b: number, c: number): void;
export function _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hda38a12a2a1c09dc(a: number, b: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3ee002e21c3855c9(a: number, b: number, c: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha7dc131e1b42f45e(a: number, b: number, c: number): void;
export function __wbindgen_add_to_stack_pointer(a: number): number;
export function __wbindgen_free(a: number, b: number, c: number): void;

View File

@ -73,7 +73,6 @@ pub fn init_camera_feed(product_options_js: JsValue) -> Result<(), String> {
};
product_options.push(test);
let video: HtmlVideoElement = get_element_by_id(VIDEO_ID).unwrap();
let canvas: HtmlCanvasElement = get_element_by_id(CANVAS_ID).unwrap();
let button: HtmlButtonElement = get_element_by_id(SCAN_BUTTON_ID).unwrap();
let search: HtmlInputElement = get_element_by_id(SEARCH_FIELD_ID).unwrap();
@ -104,23 +103,9 @@ pub fn init_camera_feed(product_options_js: JsValue) -> Result<(), String> {
succ.forget(); // Memory leak
fail.forget(); // Memory leak
let set_width_and_height: Closure<dyn FnMut()> = Closure::new(move || {
let video: HtmlVideoElement = get_element_by_id(VIDEO_ID).unwrap();
canvas.set_width(CANVAS_WIDTH);
canvas.set_height(CANVAS_HEIGHT);
let width: u32 = 1920;
let height: u32 =
((width as f32 / video.video_width() as f32) * video.video_height() as f32) as u32;
video.set_width(width);
video.set_height(height);
canvas.set_width(CANVAS_WIDTH);
canvas.set_height(CANVAS_HEIGHT);
});
let _ = video
.add_event_listener_with_callback("canplay", set_width_and_height.as_ref().unchecked_ref());
set_width_and_height.forget(); // Memory leak
//
let scan_barcode_wrapper: Closure<dyn FnMut()> = Closure::new(move || {
match scan_barcode(product_options.clone()) {
Ok(()) => {}

View File

@ -32,9 +32,8 @@
grid-column: span 12;
}
#video_container {
width: 100%;
display: none;
#video {
width: 100%;
}
/* The search field */
@ -63,15 +62,19 @@
.dropdown-content {
position: relative;
background-color: #f6f6f6;
min-width: 230px;
width: calc(100% - 2px);;
border: 1px solid #ddd;
z-index: 1;
}
.dropdown-input {
width: 100%;
}
.dropdown-options {
position: absolute;
background-color: #f6f6f6;
min-width: 230px;
width: calc(100% - 2px);;
border: 1px solid #ddd;
z-index: 1;
}

View File

@ -5,7 +5,7 @@
</div>
<div class="dropdown col-12">
<div id="myDropdown" class="dropdown-content">
<input type="text" placeholder="Search.." id="myInput">
<input type="text" placeholder="Search.." id="myInput" class="dropdown-input">
<div id="dropdownOptions" class="dropdown-options"></div>
</div>
</div>