View / apply constraints automatically based on hints

All constraints can now function differently if they are applied during
interaction or animation.
This commit is contained in:
jahow
2019-01-12 23:47:02 +01:00
committed by Olivier Guyot
parent d991dfa54a
commit e52fab636c
5 changed files with 55 additions and 27 deletions

View File

@@ -49,7 +49,11 @@ export function createSnapToN(n) {
* @param {number} delta Delta.
* @return {number|undefined} Rotation.
*/
function(rotation, delta) {
function(rotation, delta, opt_isMoving) {
if (opt_isMoving) {
return rotation;
}
if (rotation !== undefined) {
rotation = Math.floor((rotation + delta) / theta + 0.5) * theta;
return rotation;
@@ -72,7 +76,11 @@ export function createSnapToZero(opt_tolerance) {
* @param {number} delta Delta.
* @return {number|undefined} Rotation.
*/
function(rotation, delta) {
function(rotation, delta, opt_isMoving) {
if (opt_isMoving) {
return rotation;
}
if (rotation !== undefined) {
if (Math.abs(rotation + delta) <= tolerance) {
return 0;