Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration and functional option to scroll a stack without skipping images #311

Merged
merged 2 commits into from
Jan 17, 2018
Merged

Add configuration and functional option to scroll a stack without skipping images #311

merged 2 commits into from
Jan 17, 2018

Conversation

jdnarvaez
Copy link
Contributor

I wanted a way to consume scroll events and prevent the stack state from progressing to the next index until the currently request index had been drawn. I think this covers that.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 3.98% when pulling 735e0ca on jdnarvaez:jdnarvaez/scrollWithoutSkipping into 2918218 on cornerstonejs:master.

@swederik
Copy link
Member

Thanks for the contribution! I'll try to get to this ASAP, but it will likely be after the holidays.


if (config && config.loop) {
loop = config.loop;
}

scroll(eventData.element, images, loop);
if (config && config.allowSkipping !== undefined) {
Copy link
Member

@dannyrb dannyrb Dec 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to merge this check and default with the above check. For example:

Previous:

if (config && config.loop) {
  loop = config.loop;
}

Becomes:

if (config) {
  loop = config.loop !== undefined ? config.loop : false;
  allowSkipping = config.allowSkipping !== undefined ? config.allowSkipping : true;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do.

return;
}

element.addEventListener('cornerstonenewimage', function(event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing it. Is this the right event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is, as this seems to be the event that is triggered when the index actually changes.

@dannyrb
Copy link
Member

dannyrb commented Dec 24, 2017

Trying to make sure I understand. In your new implementation, you bypass the scrollToIndex and instead:

  1. Record the "pending" image change
  2. Call scrollWithoutSkipping

Where we:

  1. Verify the "pending" final scroll image is not already being displayed
  2. Register a cornerstonenewimage event listener that
    • When the next image rendered matches the next "pending image"
      • We pop of the pending image event (it's no longer pending :P)
      • Remove the listener
      • Call scrollWithoutSkipping if we have more pending items
  3. ^ Now that something is listening, we call scrollToIndex

I think this would force stackScroll requests to process in order, So if the stack scroll calls are:

  • display image 1
  • display image 2
  • display image 3
  • etc.

Then they should all display in order without skipping.

Note: I've also added some comments to your code with additional questions.

Follow-up question for @swederik, does scrollToIndex uhh.. Scroll? It looks like it queues up and loads whatever newImageId you give it?

@jdnarvaez
Copy link
Contributor Author

Correct. As far as I can tell scrollToIndex just queues the image call, which may or may not execute in order depending on how long the loadImage request takes.

@swederik
Copy link
Member

Looks good to me! Indeed scrollToIndex just queues it up.

@swederik swederik merged commit 331e6bd into cornerstonejs:master Jan 17, 2018
@adreyfus
Copy link
Member

ERROR in ./src/stackTools/stackScroll.js
/home/travis/build/cornerstonejs/cornerstoneTools/src/stackTools/stackScroll.js
  52:58  error  Parsing error: Unexpected token ||

@swederik
Copy link
Member

Thanks @adreyfus I don't know why it wasn't clear that the build was failing before I merged that...

@jdnarvaez
Copy link
Contributor Author

Sorry about that, I didn't see that either when building.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants