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 support for global fps limiting #818

Merged
merged 5 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ interface VelocityOptions {
* @default "swing"
*/
easing?: VelocityEasingType;
/**
* Maximum number of frames to render on each second for all animations
* @default 60
*/
fpsLimit?: number;
/**
* How many times should this option loop. A loop is defined as a "return to
* start values", so it will run, then reverse. This counts as a single
Expand All @@ -151,6 +156,11 @@ interface VelocityOptions {
* @default 0
*/
loop?: false | number;
/**
* The minimum frame time to achieve, the value is calculated based on fpsLimit
* @default 16,33333333
*/
minFrameTime?: number;
mobileHA?: boolean;
progress?: VelocityProgress;
/**
Expand Down
21 changes: 20 additions & 1 deletion src/Velocity/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace VelocityStatic {
_delay: number = DEFAULT_DELAY,
_duration: number = DEFAULT_DURATION,
_easing: VelocityEasingType = DEFAULT_EASING,
_fpsLimit: number = DEFAULT_FPSLIMIT,
_loop: number = DEFAULT_LOOP,
_minFrameTime: number = FUZZY_MS_PER_SECOND / DEFAULT_FPSLIMIT,
_promise: boolean = DEFAULT_PROMISE,
_promiseRejectEmpty: boolean = DEFAULT_PROMISE_REJECT_EMPTY,
_queue: string | false = DEFAULT_QUEUE,
Expand Down Expand Up @@ -90,6 +92,18 @@ namespace VelocityStatic {
}
})
},
fpsLimit: {
get: (function(): number | false {
return _fpsLimit;
}),
set: (function(value: number | false) {
value = validateFpsLimit(value);
if (value !== undefined) {
_fpsLimit = value;
_minFrameTime = FUZZY_MS_PER_SECOND / value;
}
})
},
loop: {
get: (function(): number | false {
return _loop;
Expand All @@ -101,6 +115,11 @@ namespace VelocityStatic {
}
})
},
minFrameTime:{
get: (function(): number | false {
return _minFrameTime;
})
},
promise: {
get: (function(): boolean {
return _promise;
Expand Down Expand Up @@ -146,4 +165,4 @@ namespace VelocityStatic {
})
}
});
};
};
Loading