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 f8974f4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 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,23 @@ function playClip(element, framesPerSecond) {
startLoadingHandler,
endLoadingHandler,
errorLoadingHandler,
newlastFrameTimeStamp = new Date().getTime(),
deltatime = newlastFrameTimeStamp - playClipData.lastFrameTimeStamp,
frames = Math.round((playClipData.framesPerSecond / 1000) * deltatime),
newImageIdIndex = stackData.currentImageIdIndex;

const imageCount = stackData.imageIds.length;

if (frames > 1) {
console.log('frames:', frames);
}

if (playClipData.reverse) {
newImageIdIndex--;
newImageIdIndex -= frames;
} else {
newImageIdIndex++;
newImageIdIndex += frames;
}
playClipData.lastFrameTimeStamp = newlastFrameTimeStamp;

if (
!playClipData.loop &&
Expand Down

0 comments on commit f8974f4

Please sign in to comment.