-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/hover variants #34
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** @jsxRuntime classic */ | ||
/** @jsxImportSource vue */ | ||
import { mount } from '@vue/test-utils' | ||
import Motion from '../Motion.vue' | ||
import { describe, expect, it } from 'vitest' | ||
import { delay } from '@/shared/test' | ||
|
||
describe('gesture', () => { | ||
it('hover effect triggered by parent', async () => { | ||
const wrapper = mount({ | ||
setup() { | ||
return () => ( | ||
// @ts-ignore | ||
<Motion hover="hover" data-testid="motion"> | ||
{/* @ts-ignore */} | ||
<Motion data-testid="motion-child" variants={{ hover: { scale: 1.2 } }} /> | ||
</Motion> | ||
) | ||
}, | ||
}) | ||
wrapper.find('[data-testid="motion"]').trigger('pointerenter') | ||
await delay(300) | ||
expect(wrapper.find('[data-testid="motion-child"]').element.getAttribute('style')).toBe('transform: scale(1.2);') | ||
wrapper.find('[data-testid="motion"]').trigger('pointerleave') | ||
await delay(300) | ||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test relies on hardcoded delays ( |
||
expect(wrapper.find('[data-testid="motion-child"]').element.getAttribute('style')).toBe('transform: none;') | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const delay = (ms: number) => new Promise(r => setTimeout(r, ms)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,7 +201,7 @@ export class MotionState { | |
return | ||
this.activeStates[name] = isActive | ||
this.visualElement.variantChildren?.forEach((child) => { | ||
((child as any).state as MotionState).setActive(name, isActive, false) | ||
((child as any).state as MotionState).setActive(name, isActive, !isActive) | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The recursive call to Suggested Fix: child.setActive(name, isActive, isAnimate) |
||
if (isAnimate) { | ||
this.animateUpdates() | ||
|
@@ -288,7 +288,6 @@ export class MotionState { | |
getChildAnimations = getAnimations | ||
childAnimations = animations | ||
} | ||
|
||
// Wait for all animation states to read from the DOM | ||
// yield | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ export default defineConfig({ | |
dts({ | ||
cleanVueFileName: true, | ||
outDir: 'dist', | ||
exclude: ['src/test/**', 'src/**/story/**', 'src/**/*.story.vue'], | ||
exclude: ['src/**/__tests__/**', 'src/**/story/**', 'src/**/*.story.vue'], | ||
afterBuild: async () => { | ||
// pnpm build:plugins | ||
execSync('pnpm build:plugins', { stdio: 'inherit', cwd: path.resolve(__dirname, '../plugins') }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using Suggested Change: import { exec } from 'node:child_process';
// Replace execSync with exec
exec('pnpm build:plugins', { stdio: 'inherit', cwd: path.resolve(__dirname, '../plugins') }, (error, stdout, stderr) => {
if (error) {
console.error('Error executing build:plugins:', stderr);
throw error;
}
console.log(stdout);
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation does not handle errors that may occur during the execution of the Recommendation: |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of
@ts-ignore
to bypass TypeScript's static type checking can lead to unnoticed type errors and reduce the code's maintainability. It's recommended to address the underlying type issues rather than using@ts-ignore
. This might involve updating type definitions or adjusting the usage to align with expected types.