Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Don McCurdy <donmccurdy@cartodb.com>
- Loading branch information
1 parent
3bb7fb3
commit 89189f4
Showing
16 changed files
with
593 additions
and
626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
216 changes: 0 additions & 216 deletions
216
modules/core/src/lib/attribute/attribute-transition-utils.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import {NumericArray} from '../../types/types'; | ||
|
||
export interface TransitionSettings { | ||
type: string; | ||
/** Callback to get the value that the entering vertices are transitioning from. */ | ||
enter?: (toValue: NumericArray, chunk?: NumericArray) => NumericArray; | ||
/** Callback when the transition is started */ | ||
onStart?: () => void; | ||
/** Callback when the transition is done */ | ||
onEnd?: () => void; | ||
/** Callback when the transition is interrupted */ | ||
onInterrupt?: () => void; | ||
} | ||
|
||
export type InterpolationTransitionSettings = TransitionSettings & { | ||
type?: 'interpolation'; | ||
/** Duration of the transition animation, in milliseconds */ | ||
duration: number; | ||
/** Easing function that maps a value from [0, 1] to [0, 1], see [http://easings.net/](http://easings.net/) */ | ||
easing?: (t: number) => number; | ||
}; | ||
|
||
export type SpringTransitionSettings = TransitionSettings & { | ||
type: 'spring'; | ||
/** "Tension" factor for the spring */ | ||
stiffness: number; | ||
/** "Friction" factor that counteracts the spring's acceleration */ | ||
damping: number; | ||
}; | ||
|
||
const DEFAULT_TRANSITION_SETTINGS = { | ||
interpolation: { | ||
duration: 0, | ||
easing: t => t | ||
}, | ||
spring: { | ||
stiffness: 0.05, | ||
damping: 0.5 | ||
} | ||
}; | ||
|
||
export function normalizeTransitionSettings( | ||
userSettings: number | InterpolationTransitionSettings | SpringTransitionSettings, | ||
layerSettings?: boolean | Partial<TransitionSettings> | ||
): TransitionSettings | null { | ||
if (!userSettings) { | ||
return null; | ||
} | ||
if (Number.isFinite(userSettings)) { | ||
userSettings = {type: 'interpolation', duration: userSettings as number}; | ||
} | ||
const type = (userSettings as TransitionSettings).type || 'interpolation'; | ||
return { | ||
...DEFAULT_TRANSITION_SETTINGS[type], | ||
...(layerSettings as TransitionSettings), | ||
...(userSettings as TransitionSettings), | ||
type | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.