Skip to content

Commit

Permalink
playClip works better when timer fires slowly
Browse files Browse the repository at this point in the history
  • Loading branch information
horner committed Dec 9, 2022
1 parent 925a3dd commit 744a892
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/stackTools/playClip.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function playClip(element, framesPerSecond) {
playClipData = {
intervalId: undefined,
framesPerSecond: 30,
lastFrameTimeStamp: undefined,
lastFrameTimeStamp: new Date().getTime(),
frameRate: 0,
frameTimeVector: undefined,
ignoreFrameTimeVector: false,
Expand Down Expand Up @@ -182,15 +182,19 @@ function playClip(element, framesPerSecond) {
startLoadingHandler,
endLoadingHandler,
errorLoadingHandler,
newlastFrameTimeStamp = new Date().getTime(),
deltatime = newlastFrameTimeStamp - playClipData.lastFrameTimeStamp,
frames = Math.round((playClipData.framesPerSecond / 1000) * deltatime),

Check warning on line 187 in src/stackTools/playClip.js

View check run for this annotation

Codecov / codecov/patch

src/stackTools/playClip.js#L185-L187

Added lines #L185 - L187 were not covered by tests
newImageIdIndex = stackData.currentImageIdIndex;

const imageCount = stackData.imageIds.length;

if (playClipData.reverse) {
newImageIdIndex--;
newImageIdIndex -= frames;

Check warning on line 193 in src/stackTools/playClip.js

View check run for this annotation

Codecov / codecov/patch

src/stackTools/playClip.js#L193

Added line #L193 was not covered by tests
} else {
newImageIdIndex++;
newImageIdIndex += frames;

Check warning on line 195 in src/stackTools/playClip.js

View check run for this annotation

Codecov / codecov/patch

src/stackTools/playClip.js#L195

Added line #L195 was not covered by tests
}
playClipData.lastFrameTimeStamp = newlastFrameTimeStamp;

Check warning on line 197 in src/stackTools/playClip.js

View check run for this annotation

Codecov / codecov/patch

src/stackTools/playClip.js#L197

Added line #L197 was not covered by tests

if (
!playClipData.loop &&
Expand Down

0 comments on commit 744a892

Please sign in to comment.