fix animation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { forwardRef, useCallback } from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
import { type PageData } from '../types';
|
||||
import type { EditorObject } from '@/pages/editor/store/editorStore';
|
||||
import { toCssLinearGradient } from '@/pages/editor/utils/gradient';
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from '@/pages/editor/utils/textStyle';
|
||||
import '@/pages/viewer/styles/entranceAnimations.css';
|
||||
import { mergeEntranceAnimationStyle } from '@/pages/viewer/utils/entranceAnimationStyle';
|
||||
import { useBookPageEntranceSequence } from '@/pages/viewer/hooks/useBookPageEntranceSequence';
|
||||
import type { EntrancePhase } from '@/pages/viewer/hooks/useBookEntranceController';
|
||||
|
||||
type BookPageProps = {
|
||||
page: PageData;
|
||||
@@ -28,6 +28,8 @@ type BookPageProps = {
|
||||
angle: number;
|
||||
};
|
||||
backgroundImageUrl?: string;
|
||||
/** فاز انیمیشن ورود — از BookViewer کنترل میشود */
|
||||
entrancePhase?: EntrancePhase;
|
||||
/** در پیشنمایش کاتالوگ انیمیشن ورود غیرفعال باشد */
|
||||
disableEntranceAnimations?: boolean;
|
||||
};
|
||||
@@ -40,20 +42,8 @@ type BookPageProps = {
|
||||
* نیاز به forwardRef دارد تا react-pageflip بتواند ref را مدیریت کند
|
||||
*/
|
||||
const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
({ page, scale = 1, pageWidth, pageHeight, onLinkClick, backgroundType, backgroundColor, backgroundGradient, backgroundImageUrl, disableEntranceAnimations = false }, ref) => {
|
||||
const { attachRootRef, entranceSeq } = useBookPageEntranceSequence(disableEntranceAnimations);
|
||||
|
||||
const setHostRef = useCallback(
|
||||
(node: HTMLDivElement | null) => {
|
||||
attachRootRef(node);
|
||||
if (typeof ref === 'function') {
|
||||
ref(node);
|
||||
} else if (ref) {
|
||||
(ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
|
||||
}
|
||||
},
|
||||
[ref, attachRootRef],
|
||||
);
|
||||
({ page, scale = 1, pageWidth, pageHeight, onLinkClick, backgroundType, backgroundColor, backgroundGradient, backgroundImageUrl, entrancePhase = 'idle', disableEntranceAnimations = false }, ref) => {
|
||||
const phase: EntrancePhase = disableEntranceAnimations ? 'settled' : entrancePhase;
|
||||
// تابع برای تبدیل opacity به رنگ (مثل editor)
|
||||
// در editor، getColorWithOpacity انتظار opacity 0-100 دارد
|
||||
// در dataTransformer، opacity از 0-1 به 0-100 تبدیل شده است
|
||||
@@ -97,7 +87,7 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
rotationDeg?: number;
|
||||
},
|
||||
) =>
|
||||
mergeEntranceAnimationStyle(style, obj, scale, index, entranceSeq, {
|
||||
mergeEntranceAnimationStyle(style, obj, scale, index, phase, {
|
||||
...extra,
|
||||
flyLayoutPx,
|
||||
});
|
||||
@@ -664,7 +654,7 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={setHostRef}
|
||||
ref={ref}
|
||||
dir="rtl"
|
||||
className="page"
|
||||
data-density="soft"
|
||||
|
||||
Reference in New Issue
Block a user