Skip to content

Commit 56fc942

Browse files
authored
Fix for resize events when building with ASSERTIONS (#21362)
Building with ASSERTIONS is failing the safe heap checks when e.detail is undefined.
1 parent c6eacb9 commit 56fc942

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

site/source/docs/api_reference/html5.h.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ Struct
596596
597597
.. c:member:: long detail
598598
599-
Specifies additional detail/information about this event.
599+
For resize and scroll events this is always zero.
600600
601601
.. c:member:: int documentBodyClientWidth
602602
int documentBodyClientHeight
@@ -616,7 +616,7 @@ Struct
616616
.. c:member:: int scrollTop
617617
int scrollLeft
618618
619-
The page scroll position.
619+
The page scroll position (rounded down to the nearest pixel).
620620
621621
622622
Callback functions

src/library_html5.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,15 +710,15 @@ var LibraryHTML5 = {
710710
#else
711711
var uiEvent = JSEvents.uiEvent;
712712
#endif
713-
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.detail, 'e.detail', 'i32') }}};
713+
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.detail, '0', 'i32') }}}; // always zero for resize and scroll
714714
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.documentBodyClientWidth, 'b.clientWidth', 'i32') }}};
715715
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.documentBodyClientHeight, 'b.clientHeight', 'i32') }}};
716716
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.windowInnerWidth, 'innerWidth', 'i32') }}};
717717
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.windowInnerHeight, 'innerHeight', 'i32') }}};
718718
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.windowOuterWidth, 'outerWidth', 'i32') }}};
719719
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.windowOuterHeight, 'outerHeight', 'i32') }}};
720-
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.scrollTop, 'pageXOffset', 'i32') }}};
721-
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.scrollLeft, 'pageYOffset', 'i32') }}};
720+
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.scrollTop, 'pageXOffset | 0', 'i32') }}}; // scroll offsets are float
721+
{{{ makeSetValue('uiEvent', C_STRUCTS.EmscriptenUiEvent.scrollLeft, 'pageYOffset | 0', 'i32') }}};
722722
#if PTHREADS
723723
if (targetThread) __emscripten_run_callback_on_thread(targetThread, callbackfunc, eventTypeId, uiEvent, userData);
724724
else

0 commit comments

Comments
 (0)