View in #cornerstone3d on Slack
@Steph_Vallance: Hi! 
Can I please get some assistance with the StackScrollTool
?
I need to listen to the STACK_VIEWPORT_SCROLL
event but it doesn’t seem to be firing. As a sanity check, I’ve changed the Basic Stack Manipulation example to trigger the event, and it doesn’t seem to be working there either.
eg. I added:
eventTarget.addEventListener(STACK_VIEWPORT_SCROLL, ((
evt: any
) => {
updateLastEvents(
eventNumber,
STACK_VIEWPORT_SCROLL,
JSON.stringify(evt.detail)
);
eventNumber++;
}) as EventListener);
immediately after the event listener for STACK_SCROLL_OUT_OF_BOUNDS
- out of bounds triggers as expected, but nothing from the stack scroll.
Is this a bug (happy to raise one!) Or am I missing something?
![Syed_Pasha_[Ramsoft]] @Syed_Pasha_[Ramsoft]: you’re right. the scroll event is not firing for some reason.
can you try this
cornerstone.getEnabledElements()[0].viewport.element.addEventListener(cornerstone.EVENTS.STACK_VIEWPORT_SCROLL, (e) => {
console.log("boom")
})
![Peter_Newhook] @Peter_Newhook: Correct, the scroll event is fired on the viewport element, not the eventTarget
![Syed_Pasha_[Ramsoft]] @Syed_Pasha_[Ramsoft]: i searched for triggerEvent
usage in cornerstone3d repo and it shows that some events are triggered on viewport element
and some on the eventTarget
.
i can’t seem to understand why this difference.
events in StackViewport.ts:
in StackViewport.ts file almost all of the events are triggered on element. eg: camera_modified
, voi_modified
, (viewport/stack/pre_fetch)__new__image
and only one event is triggered on target. eg: image_load_error
surely there must be some reason behind this sort of usage?
@Steph_Vallance: @Syed_Pasha_[Ramsoft] that’s solved my problem! Thank you so much, great catch. 
Also curious to understand the inconsistency on target vs element here