-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stopAnimation trigger finish event (#203)
* fix: stopAnimation trigger finish event * fix: trigger finish only when stopAnimation by method * fix: set animateParam as null * fix: check new duration by nullish coalescing * chore: fix typo * chore: fix unit test * docs: add PanInput to axes logo * chore: update demo build path
- Loading branch information
Showing
15 changed files
with
197 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,4 +198,3 @@ outjs/ | |
declaration/ | ||
packages/*/dist/ | ||
dist/ | ||
demo/ |
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,37 @@ | ||
#container { | ||
display: flex; | ||
justify-content: center; | ||
position: relative; | ||
width: 100%; | ||
height: 320px; | ||
margin-top: 40px; | ||
} | ||
|
||
.item { | ||
z-index: 2; | ||
cursor: grab; | ||
} | ||
|
||
.item svg { | ||
position: absolute; | ||
width: 50px; | ||
height: 50px; | ||
} | ||
|
||
.item.light svg { | ||
width: 60px; | ||
margin-left: -5px; | ||
} | ||
|
||
.item.bold svg { | ||
width: 50px; | ||
height: 40px; | ||
padding-top: 5px; | ||
} | ||
|
||
.line { | ||
z-index: 1; | ||
position: absolute; | ||
width: 100%; | ||
height: 320px; | ||
} |
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,116 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { useAxes, PanInput } from "@egjs/react-axes"; | ||
import "../../css/demos/logo.css"; | ||
|
||
import SquareIcon from "../../../static/img/demos/logo/square.svg"; | ||
import TriangleIcon from "../../../static/img/demos/logo/triangle.svg"; | ||
import CircleIcon from "../../../static/img/demos/logo/circle.svg"; | ||
import XIcon from "../../../static/img/demos/logo/x.svg"; | ||
import YIcon from "../../../static/img/demos/logo/y.svg"; | ||
import ZIcon from "../../../static/img/demos/logo/z.svg"; | ||
|
||
export default function Logo() { | ||
const [offsetX1, setOffsetX1] = useState(null); | ||
const [offsetX2, setOffsetX2] = useState(null); | ||
const offsetY = 25; | ||
const square = useAxes({ | ||
x: { | ||
range: [-200, 150], | ||
startPos: -125, | ||
}, | ||
y: { | ||
range: [0, 275], | ||
startPos: 55, | ||
}, | ||
}); | ||
const triangle = useAxes({ | ||
x: { | ||
range: [-200, 150], | ||
startPos: -125, | ||
}, | ||
y: { | ||
range: [0, 275], | ||
startPos: 135, | ||
}, | ||
}); | ||
const circle = useAxes({ | ||
x: { | ||
range: [-200, 150], | ||
startPos: -125, | ||
}, | ||
y: { | ||
range: [0, 275], | ||
startPos: 215, | ||
}, | ||
}); | ||
const x = useAxes({ | ||
x: { | ||
range: [-200, 150], | ||
startPos: 75, | ||
}, | ||
y: { | ||
range: [0, 275], | ||
startPos: 55, | ||
}, | ||
}); | ||
const y = useAxes({ | ||
x: { | ||
range: [-200, 150], | ||
startPos: 75, | ||
}, | ||
y: { | ||
range: [0, 275], | ||
startPos: 135, | ||
}, | ||
}); | ||
const z = useAxes({ | ||
x: { | ||
range: [-200, 150], | ||
startPos: 75, | ||
}, | ||
y: { | ||
range: [0, 275], | ||
startPos: 215, | ||
}, | ||
}); | ||
|
||
useEffect(() => { | ||
const container = document.getElementById("container"); | ||
const containerWidth = container.getBoundingClientRect().width; | ||
setOffsetX1(60 + containerWidth / 2); | ||
setOffsetX2(containerWidth / 2); | ||
square.connect("x y", new PanInput("#square")); | ||
triangle.connect("x y", new PanInput("#triangle")); | ||
circle.connect("x y", new PanInput("#circle")); | ||
x.connect("x y", new PanInput("#x")); | ||
y.connect("x y", new PanInput("#y")); | ||
z.connect("x y", new PanInput("#z")); | ||
[square, triangle, circle, x, y, x].forEach(axes => { | ||
axes.setAxis({ | ||
x: { | ||
range: [-(containerWidth / 2) + 10, (containerWidth / 2) - 60], | ||
} | ||
}); | ||
}) | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<div id="container" style={{ opacity: `${offsetX1 ? "1" : "0"}` }}> | ||
<div id="square" className="item" style={{ transform: `translateX(${square.x}px) translateY(${square.y}px)` }}><SquareIcon /></div> | ||
<div id="triangle" className="item light" style={{ transform: `translateX(${triangle.x}px) translateY(${triangle.y}px)` }}><TriangleIcon /></div> | ||
<div id="circle" className="item" style={{ transform: `translateX(${circle.x}px) translateY(${circle.y}px)` }}><CircleIcon /></div> | ||
<div id="x" className="item bold" style={{ transform: `translateX(${x.x}px) translateY(${x.y}px)` }}><XIcon /></div> | ||
<div id="y" className="item" style={{ transform: `translateX(${y.x}px) translateY(${y.y}px)` }}><YIcon /></div> | ||
<div id="z" className="item bold" style={{ transform: `translateX(${z.x}px) translateY(${z.y}px)` }}><ZIcon /></div> | ||
<svg className="line"><line x1={ offsetX1 + square.x } y1={ offsetY + square.y } x2={ offsetX2 + x.x } y2={ offsetY + x.y } stroke="black" strokeWidth="4"/></svg> | ||
<svg className="line"><line x1={ offsetX1 + square.x } y1={ offsetY + square.y } x2={ offsetX2 + y.x } y2={ offsetY + y.y } stroke="black" strokeWidth="4"/></svg> | ||
<svg className="line"><line x1={ offsetX1 + triangle.x } y1={ offsetY + triangle.y } x2={ offsetX2 + x.x } y2={ offsetY + x.y } stroke="black" strokeWidth="4"/></svg> | ||
<svg className="line"><line x1={ offsetX1 + triangle.x } y1={ offsetY + triangle.y } x2={ offsetX2 + y.x } y2={ offsetY + y.y } stroke="black" strokeWidth="4"/></svg> | ||
<svg className="line"><line x1={ offsetX1 + triangle.x } y1={ offsetY + triangle.y } x2={ offsetX2 + z.x } y2={ offsetY + z.y } stroke="black" strokeWidth="4"/></svg> | ||
<svg className="line"><line x1={ offsetX1 + circle.x } y1={ offsetY + circle.y } x2={ offsetX2 + y.x } y2={ offsetY + y.y } stroke="black" strokeWidth="4"/></svg> | ||
<svg className="line"><line x1={ offsetX1 + circle.x } y1={ offsetY + circle.y } x2={ offsetX2 + z.x } y2={ offsetY + z.y } stroke="black" strokeWidth="4"/></svg> | ||
</div> | ||
</div> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.