-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 generic interface AnimationObject over type and options
AnimationObject interface is now generic over type of the animation and the options the animation of the type can accept. It is simplifies implementing new animations where you can specify your type of AnimationObject just using generic one. Also, it adds a possibility for TypeScript to infer some of the types when using these interfaces.
- Loading branch information
Showing
12 changed files
with
85 additions
and
65 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
6 changes: 3 additions & 3 deletions
6
packages/kittik-animation-basic/src/animation/AnimationObject.ts
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { AnimationOptions } from './AnimationOptions'; | ||
|
||
export interface AnimationObject { | ||
type: string | ||
options?: Partial<AnimationOptions> | ||
export interface AnimationObject<T, O extends AnimationOptions> { | ||
type: T | ||
options: O | ||
} |
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import { AnimationObject } from 'kittik-animation-basic'; | ||
import { FocusOptions } from './FocusOptions'; | ||
|
||
export interface FocusObject extends AnimationObject { | ||
options?: Partial<FocusOptions> | ||
} | ||
export type FocusObject = AnimationObject<'Focus', FocusOptions>; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { AnimationObject } from 'kittik-animation-basic'; | ||
import { PrintOptions } from './PrintOptions'; | ||
|
||
export type PrintObject = AnimationObject; | ||
export type PrintObject = AnimationObject<'Print', PrintOptions>; |
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import { AnimationObject } from 'kittik-animation-basic'; | ||
import { SlideOptions } from './SlideOptions'; | ||
|
||
export interface SlideObject extends AnimationObject { | ||
options?: Partial<SlideOptions> | ||
} | ||
export type SlideObject = AnimationObject<'Slide', SlideOptions>; |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { AnimationOptions, AnimationType } from './Animations'; | ||
import { AnimationObject } from 'kittik-animation-basic'; | ||
|
||
export interface AnimationDeclaration extends AnimationObject { | ||
export interface AnimationDeclaration extends AnimationObject<AnimationType, AnimationOptions<AnimationType>> { | ||
name: string | ||
} |
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