-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add builtin animations and namespaced module
- Loading branch information
Showing
9 changed files
with
127 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import type { TransitionDirectionalAnimations, TransitionAnimationPair } from '../@types/astro'; | ||
|
||
export function slide({ | ||
duration | ||
}: { | ||
duration?: string | number; | ||
} = {}): TransitionDirectionalAnimations { | ||
return { | ||
forwards: { | ||
old: [{ | ||
name: 'astroFadeOut', | ||
duration: duration ?? '90ms', | ||
easing: 'cubic-bezier(0.4, 0, 1, 1)', | ||
fillMode: 'both' | ||
}, { | ||
name: 'astroSlideToLeft', | ||
duration: duration ?? '300ms', | ||
easing: 'cubic-bezier(0.4, 0, 0.2, 1)', | ||
fillMode: 'both' | ||
}], | ||
new: [{ | ||
name: 'astroFadeIn', | ||
duration: duration ?? '210ms', | ||
easing: 'cubic-bezier(0, 0, 0.2, 1)', | ||
delay: '90ms', | ||
fillMode: 'both' | ||
}, { | ||
name: 'astroSlideFromRight', | ||
duration: duration ?? '300ms', | ||
easing: 'cubic-bezier(0.4, 0, 0.2, 1)', | ||
fillMode: 'both' | ||
}] | ||
}, | ||
backwards: { | ||
old: [{ name: 'astroFadeOut' }, { name: 'astroSlideToRight' }], | ||
new: [{ name: 'astroFadeIn' }, { name: 'astroSlideFromLeft' }] | ||
} | ||
}; | ||
} | ||
|
||
export function fade({ | ||
duration | ||
}: { | ||
duration?: string | number; | ||
}): TransitionDirectionalAnimations { | ||
const anim = { | ||
old: { | ||
name: 'astroFadeInOut', | ||
duration: duration ?? '0.2s', | ||
easing: 'linear', | ||
direction: 'forwards', | ||
}, | ||
new: { | ||
name: 'astroFadeInOut', | ||
duration: duration ?? '0.3s', | ||
easing: 'linear', | ||
direction: 'backwards', | ||
} | ||
} satisfies TransitionAnimationPair; | ||
|
||
return { | ||
forwards: anim, | ||
backwards: anim, | ||
}; | ||
} |
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,25 @@ | ||
import * as vite from 'vite'; | ||
|
||
const virtualModuleId = 'astro:transitions'; | ||
|
||
// The virtual module for the astro:transitions namespace | ||
export default function astroTransitions(): vite.Plugin { | ||
const resolvedVirtualModuleId = '\0' + virtualModuleId; | ||
|
||
return { | ||
name: 'astro:transitions', | ||
async resolveId(id) { | ||
if (id === virtualModuleId) { | ||
return resolvedVirtualModuleId; | ||
} | ||
}, | ||
load(id) { | ||
if (id === resolvedVirtualModuleId) { | ||
return ` | ||
export * from "astro/transitions"; | ||
export { default as ViewTransitions } from "astro/components/ViewTransitions.astro"; | ||
`; | ||
} | ||
}, | ||
}; | ||
} |
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