-
Notifications
You must be signed in to change notification settings - Fork 124
feat: add initial motion.dev support for Lynx #1062
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
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
4d03971
feat: add initial motion support for lynx
f0rdream daf0ccd
feat: add more features like motionValue, springValue
f0rdream 37f1592
feat: add useMotionValueRefEvent
f0rdream 8e5ec1b
feat: use prototype monkey-patch to do with MotionValue toJSON
f0rdream 79e20a9
feat: add styleEffect
f0rdream d802bea
chore: update node version
f0rdream 9416f31
fix: types conflict
f0rdream 993520b
feat: add useMotionValueRefEvent
f0rdream 6b20026
fix: motion reset transform bug
f0rdream 1d1ad31
fix: shim conflict on web
f0rdream 4d826c0
feat(react): shared runtime imports
Yradex f27abc9
Merge branch 'motion_lynx_tmp' into mts/dev-2
f0rdream 76d6bc8
feat: use shared module
f0rdream ca75aaf
fix: motion not query right element
f0rdream 8bbc408
fix: motion not query right element
f0rdream fda5877
feat: motion mini
f0rdream a0d24eb
Merge branch 'mts/dev-2' into motion_lynx
f0rdream 7c08daa
chore: update dist artifacts after merge
f0rdream 41f9f85
feat: remove dist
f0rdream d4f1fe3
feat: rename into xx_
f0rdream 2e01030
Merge branch 'main' into motion_lynx
f0rdream 9fc7e10
feat: rename into @lynx-js/motion
f0rdream e9e8187
feat: add more tests for motion
f0rdream 5205f01
Merge branch 'main' into motion_lynx
f0rdream e460d91
chore: update the tsconfig hierarchy
f0rdream 9697d3c
Merge branch 'main' into motion_lynx
f0rdream b2b9e3d
style: add comments for useMotionValueRef
f0rdream 0752985
chore: update tsconfig for motion
f0rdream b93796a
chore: revert prepare commands back
f0rdream 76f72ee
Merge branch 'main' into motion_lynx
f0rdream 459fdf4
fix: motion example test types
f0rdream 144f4a8
style: add useMotionValueRef comments
f0rdream 8aca1a7
chore: fix motion eslint errors
f0rdream af9888a
chore: fix eslint error
f0rdream 5ccf97f
chore: react build dependents
f0rdream c977ec5
Merge branch 'main' into motion_lynx
f0rdream 00665e0
fix: remove document import
f0rdream 33fee2f
Merge branch 'main' into motion_lynx
f0rdream 0c25946
chore: fix coding style problems
f0rdream c8ab4cd
Merge branch 'main' into motion_lynx
f0rdream 91b18b3
chore: turn off rslib build cache to prevent building crash
f0rdream 9058fc5
Merge branch 'main' into motion_lynx
f0rdream 2b584aa
Merge branch 'main' into motion_lynx
f0rdream 1527594
chore: add changeset
f0rdream 8b891d4
chore: remove empty changeset
f0rdream 2c4892e
fix: animate accepts strings to be animated
f0rdream 533a3e8
Merge branch 'main' into motion_lynx
f0rdream d76dcf9
fix: animate string test
f0rdream e95f4e2
fix: warn unsupported options for mini animate
f0rdream d09c41a
Merge branch 'main' into motion_lynx
f0rdream 5a6a2b2
Merge branch 'main' into motion_lynx
f0rdream File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@lynx-js/motion': patch | ||
| --- | ||
|
|
||
| Add initial support for `@lynx-js/motion` |
This file contains hidden or 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 hidden or 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 hidden or 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,26 @@ | ||
| import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin'; | ||
| import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'; | ||
| import { defineConfig } from '@lynx-js/rspeedy'; | ||
|
|
||
| const enableBundleAnalysis = !!process.env['RSPEEDY_BUNDLE_ANALYSIS']; | ||
|
|
||
| export default defineConfig({ | ||
| source: { | ||
| entry: { | ||
| main: './src/index.tsx', | ||
| mini: './src/Mini/index.tsx', | ||
| }, | ||
| }, | ||
| plugins: [ | ||
| pluginReactLynx(), | ||
| pluginQRCode({ | ||
| schema(url) { | ||
| // We use `?fullscreen=true` to open the page in LynxExplorer in full screen mode | ||
| return `${url}?fullscreen=true`; | ||
| }, | ||
| }), | ||
| ], | ||
| performance: { | ||
| profile: enableBundleAnalysis, | ||
| }, | ||
| }); |
This file contains hidden or 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,22 @@ | ||
| { | ||
| "name": "@lynx-js/motion-examples", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "rspeedy build", | ||
| "dev": "rspeedy dev" | ||
| }, | ||
| "dependencies": { | ||
| "@lynx-js/motion": "workspace:*", | ||
| "@lynx-js/react": "workspace:*" | ||
| }, | ||
| "devDependencies": { | ||
| "@lynx-js/preact-devtools": "^5.0.1-cf9aef5", | ||
| "@lynx-js/qrcode-rsbuild-plugin": "workspace:*", | ||
| "@lynx-js/react-rsbuild-plugin": "workspace:*", | ||
| "@lynx-js/rspeedy": "workspace:*", | ||
| "@lynx-js/types": "3.6.0", | ||
| "@types/react": "^18.3.25" | ||
| } | ||
| } |
This file contains hidden or 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,30 @@ | ||
| .case-area { | ||
| flex: 1; | ||
| } | ||
|
|
||
| .container { | ||
| width: 100%; | ||
| height: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding-top: 60px; | ||
| } | ||
|
|
||
| .button-area { | ||
| display: flex; | ||
| flex-direction: row; | ||
| gap: 20px; | ||
| padding: 0 16px; | ||
| flex-wrap: wrap; | ||
| } | ||
|
|
||
| .text-area { | ||
| padding: 16px 16px; | ||
| } | ||
|
|
||
| .button { | ||
| border-radius: 16px; | ||
| padding: 8px; | ||
| border: 1px solid #333; | ||
| flex-shrink: 0; | ||
| } |
This file contains hidden or 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,90 @@ | ||
| import { useState } from '@lynx-js/react'; | ||
|
|
||
| import Basic from './Basic/index.js'; | ||
| import BasicPercent from './BasicPercent/index.js'; | ||
| import BasicSelector from './BasicSelector/index.js'; | ||
| import ColorInterception from './ColorInterception/index.js'; | ||
| import iOSSlider from './iOSSlider/index.js'; | ||
| import Mini from './Mini/index.js'; | ||
| import MotionValue from './MotionValue/index.js'; | ||
| import Spring from './Spring/index.js'; | ||
| import Stagger from './Stagger/index.js'; | ||
| import Text from './Text/index.js'; | ||
|
|
||
| import './App.css'; | ||
|
|
||
| interface CaseItem { | ||
| name: string; | ||
| comp: () => JSX.Element; | ||
| } | ||
|
|
||
| const CASES: CaseItem[] = [ | ||
| { | ||
| name: 'Basic', | ||
| comp: Basic, | ||
| }, | ||
| { | ||
| name: 'BasicPercent', | ||
| comp: BasicPercent, | ||
| }, | ||
| { | ||
| name: 'Stagger', | ||
| comp: Stagger, | ||
| }, | ||
| { | ||
| name: 'ColorInterception', | ||
| comp: ColorInterception, | ||
| }, | ||
| { | ||
| name: 'Spring', | ||
| comp: Spring, | ||
| }, | ||
| { | ||
| name: 'Text', | ||
| comp: Text, | ||
| }, | ||
| { | ||
| name: 'BasicSelector', | ||
| comp: BasicSelector, | ||
| }, | ||
| { | ||
| name: 'MotionValue', | ||
| comp: MotionValue, | ||
| }, | ||
| { | ||
| name: 'iOSSlider', | ||
| comp: iOSSlider, | ||
| }, | ||
| { | ||
| name: 'Mini', | ||
| comp: Mini, | ||
| }, | ||
| ]; | ||
|
|
||
| export function App() { | ||
| const [current, setCurrent] = useState(0); | ||
|
|
||
| const CurrentComp = CASES[current]?.comp; | ||
|
|
||
| return ( | ||
| <view className='container'> | ||
| <view className='button-area'> | ||
| {CASES.map((item, index) => { | ||
| return ( | ||
| <view | ||
| key={item.name} | ||
| className='button' | ||
| bindtap={() => setCurrent(index)} | ||
| > | ||
| <text>{item.name}</text> | ||
| </view> | ||
| ); | ||
| })} | ||
| </view> | ||
| <text className='text-area'>Current case is: {CASES[current]?.name}</text> | ||
| <view className='case-area'> | ||
| {CurrentComp && <CurrentComp />} | ||
| </view> | ||
| </view> | ||
| ); | ||
| } |
This file contains hidden or 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,61 @@ | ||
| import { animate } from '@lynx-js/motion'; | ||
| import { runOnMainThread, useEffect, useMainThreadRef } from '@lynx-js/react'; | ||
| import type { MainThread } from '@lynx-js/types'; | ||
|
|
||
| import './styles.css'; | ||
|
|
||
| export default function Basic() { | ||
| const animateMTRef = useMainThreadRef<ReturnType<typeof animate> | null>( | ||
| null, | ||
| ); | ||
| const boxMTRef = useMainThreadRef<MainThread.Element>(null); | ||
|
|
||
| function startAnimation() { | ||
| 'main thread'; | ||
|
|
||
| if (boxMTRef.current) { | ||
| animateMTRef.current = animate( | ||
| boxMTRef.current, | ||
| { scale: 0.4, rotate: '45deg' }, | ||
| { | ||
| ease: 'circInOut', | ||
| duration: 1, | ||
| repeat: Number.POSITIVE_INFINITY, | ||
| repeatType: 'reverse', | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function endAnimation() { | ||
| 'main thread'; | ||
|
|
||
| animateMTRef.current?.stop(); | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| const timeoutId = setTimeout(() => { | ||
| void runOnMainThread(startAnimation)(); | ||
| }, 1500); | ||
| return () => { | ||
| clearTimeout(timeoutId); | ||
| void runOnMainThread(endAnimation)(); | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <view className='case-container'> | ||
| <view | ||
| main-thread:ref={boxMTRef} | ||
| style={{ | ||
| width: '100px', | ||
| height: '100px', | ||
| backgroundColor: '#8df0cc', | ||
| borderRadius: '10px', | ||
| transform: 'scale(1.5)', | ||
| }} | ||
| > | ||
| </view> | ||
| </view> | ||
| ); | ||
| } | ||
This file contains hidden or 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,6 @@ | ||
| .case-container { | ||
| height: 100%; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } |
This file contains hidden or 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,57 @@ | ||
| import { animate } from '@lynx-js/motion'; | ||
| import { runOnMainThread, useEffect, useMainThreadRef } from '@lynx-js/react'; | ||
| import type { MainThread } from '@lynx-js/types'; | ||
|
|
||
| import './styles.css'; | ||
|
|
||
| export default function BasicPercent() { | ||
| const animateMTRef = useMainThreadRef<ReturnType<typeof animate> | null>( | ||
| null, | ||
| ); | ||
| const boxMTRef = useMainThreadRef<MainThread.Element>(null); | ||
|
|
||
| function startAnimation() { | ||
| 'main thread'; | ||
|
|
||
| if (boxMTRef.current) { | ||
| animateMTRef.current = animate( | ||
| boxMTRef.current, | ||
| { width: ['10px', '50px'] }, | ||
| { | ||
| ease: 'circInOut', | ||
| duration: 1, | ||
| repeat: Number.POSITIVE_INFINITY, | ||
| repeatType: 'reverse', | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function endAnimation() { | ||
| 'main thread'; | ||
|
|
||
| animateMTRef.current?.stop(); | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| void runOnMainThread(startAnimation)(); | ||
| return () => { | ||
| void runOnMainThread(endAnimation)(); | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <view className='case-container'> | ||
| <view | ||
| main-thread:ref={boxMTRef} | ||
| style={{ | ||
| width: '300px', | ||
| height: '100px', | ||
| backgroundColor: '#8df0cc', | ||
| borderRadius: '10px', | ||
| }} | ||
| > | ||
| </view> | ||
| </view> | ||
| ); | ||
| } | ||
This file contains hidden or 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,6 @@ | ||
| .case-container { | ||
| height: 100%; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } |
This file contains hidden or 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,56 @@ | ||
| import { animate } from '@lynx-js/motion'; | ||
| import { runOnMainThread, useEffect, useMainThreadRef } from '@lynx-js/react'; | ||
|
|
||
| import './styles.css'; | ||
|
|
||
| export default function Basic() { | ||
| const animateMTRef = useMainThreadRef<ReturnType<typeof animate> | null>( | ||
| null, | ||
| ); | ||
|
|
||
| function startAnimation() { | ||
| 'main thread'; | ||
| animateMTRef.current = animate( | ||
| '.box', | ||
| { scale: 0.4, rotate: '45deg' }, | ||
| { | ||
| ease: 'circInOut', | ||
| duration: 1, | ||
| repeat: Number.POSITIVE_INFINITY, | ||
| repeatType: 'reverse', | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| function endAnimation() { | ||
| 'main thread'; | ||
|
|
||
| animateMTRef.current?.stop(); | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| const timeoutId = setTimeout(() => { | ||
| void runOnMainThread(startAnimation)(); | ||
| }, 1000); | ||
| return () => { | ||
| clearTimeout(timeoutId); | ||
| void runOnMainThread(endAnimation)(); | ||
| }; | ||
| }, []); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <view className='case-container'> | ||
| <view | ||
| className='box' | ||
| style={{ | ||
| width: '100px', | ||
| height: '100px', | ||
| backgroundColor: '#8df0cc', | ||
| borderRadius: '10px', | ||
| transform: 'scale(1.5)', | ||
| }} | ||
| > | ||
| </view> | ||
| </view> | ||
| ); | ||
| } | ||
This file contains hidden or 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,6 @@ | ||
| .case-container { | ||
| height: 100%; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.