-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f68082f
commit 80c1fd4
Showing
19 changed files
with
169 additions
and
104 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
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
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
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 |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import type { Methodize } from '@vue-motion/core' | ||
import { defineAnimation } from '@vue-motion/core' | ||
import { interpolator } from '../interpolator' | ||
|
||
export interface Rotatable { | ||
rotation?: number | ||
} | ||
export type RotatableMethods = Methodize<Rotatable, { rotateTo: ['rotation'] }> | ||
|
||
export const rotate = defineAnimation<{ | ||
from?: number | ||
offset?: number | ||
}, Rotatable>((context, progress) => { | ||
if (progress === 0) { | ||
context.from ??= context.target.rotation ?? 0 | ||
context.from ??= target.rotation ?? 0 | ||
} | ||
context.target.rotation = context.from! + interpolator(0, context.offset!, progress) | ||
target.rotation = context.from! + interpolator(0, context.offset!, progress) | ||
}) | ||
|
||
export const rotateTo = defineAnimation<{ | ||
from?: number | ||
to?: number | ||
}, Rotatable>((context, progress) => { | ||
if (progress === 0) { | ||
context.from ??= context.target.rotation ?? 0 | ||
context.from ??= target.rotation ?? 0 | ||
} | ||
context.target.rotation = interpolator(context.from!, context.to!, progress) | ||
target.rotation = interpolator(context.from!, context.to!, progress) | ||
}) |
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.