Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add note changing animation

thecodrrc493a46aa26a
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 40a4e2ef7..eea628aa6 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -16,6 +16,7 @@ import Header from "./header";
import { useHashParam } from "../../utils/useHashParam";
import SplitEditor from "../spliteditor";
import Unlock from "../unlock";
+import { useAnimation } from "framer-motion";
function Editor() {
console.log("rendering editor");
@@ -26,6 +27,7 @@ function Editor() {
const updateWordCount = useStore((store) => store.updateWordCount);
const init = useStore((store) => store.init);
const isFocusMode = useAppStore((store) => store.isFocusMode);
+ const animation = useAnimation();
const isTrial = useUserStore(
(store) => store.user.notesnook?.subscription?.isTrial
);
@@ -48,6 +50,30 @@ function Editor() {
init();
}, [init]);
+ useEffect(() => {
+ if (sessionState === SESSION_STATES.new) {
+ animation
+ .start({
+ opacity: 0,
+ transition: { duration: 0.1 },
+ })
+ .then(() =>
+ animation
+ .start({
+ x: -100,
+ transition: { duration: 0 },
+ })
+ .then(() =>
+ animation.start({
+ opacity: 1,
+ x: 0,
+ transition: { duration: 0.1 },
+ })
+ )
+ );
+ }
+ }, [sessionState, animation]);
+
useEffect(() => {
if (!quillRef || !quillRef.current) return;
@@ -87,33 +113,35 @@ function Editor() {
<Header />
<Flex id="toolbar" />
<EditorMenu quill={quillRef.current && quillRef.current.quill} />
- <ReactQuill
- id="quill"
- ref={quillRef}
- refresh={sessionState === SESSION_STATES.new}
- isSimple={isLoggedin || !isTrial}
- onFocus={() => {
- toggleProperties(false);
- }}
- placeholder="Type anything here"
- container=".editor"
- onSave={() => {
- saveSession();
- }}
- changeInterval={500}
- onWordCountChanged={updateWordCount}
- onChange={() => {
- const { quill } = quillRef.current;
- const delta = quill.getContents().ops;
- const text = quill.getText();
- setSession((state) => {
- state.session.content = {
- delta: { ops: delta },
- text: text,
- };
- });
- }}
- />
+ <Animated.Flex initial={{ opacity: 0 }} animate={animation}>
+ <ReactQuill
+ id="quill"
+ ref={quillRef}
+ refresh={sessionState === SESSION_STATES.new}
+ isSimple={isLoggedin || !isTrial}
+ onFocus={() => {
+ toggleProperties(false);
+ }}
+ placeholder="Type anything here"
+ container=".editor"
+ onSave={() => {
+ saveSession();
+ }}
+ changeInterval={500}
+ onWordCountChanged={updateWordCount}
+ onChange={() => {
+ const { quill } = quillRef.current;
+ const delta = quill.getContents().ops;
+ const text = quill.getText();
+ setSession((state) => {
+ state.session.content = {
+ delta: { ops: delta },
+ text: text,
+ };
+ });
+ }}
+ />
+ </Animated.Flex>
</Flex>
<Properties />
</Animated.Flex>