|
@@ -10,10 +10,6 @@ import { gsap, ScrollTrigger } from "gsap/all";
|
|
import LazyLoad from "react-lazyload";
|
|
import LazyLoad from "react-lazyload";
|
|
import { css } from "@emotion/react";
|
|
import { css } from "@emotion/react";
|
|
|
|
|
|
-// const isDebug = Number(import.meta.env.VITE_APP_DEBUG) === 1;
|
|
|
|
-const isDebug = false;
|
|
|
|
-console.log("isDebug", isDebug);
|
|
|
|
-
|
|
|
|
export default function Viewer(props) {
|
|
export default function Viewer(props) {
|
|
const lazyHeight = 0.01 * parseFloat(props.height) * window.innerHeight;
|
|
const lazyHeight = 0.01 * parseFloat(props.height) * window.innerHeight;
|
|
// offset={1e4}
|
|
// offset={1e4}
|
|
@@ -21,14 +17,17 @@ export default function Viewer(props) {
|
|
return isValidElement(element)
|
|
return isValidElement(element)
|
|
? cloneElement(element, {
|
|
? cloneElement(element, {
|
|
parentHeight: props.height,
|
|
parentHeight: props.height,
|
|
|
|
+ debug: props.debug,
|
|
})
|
|
})
|
|
: element;
|
|
: element;
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+ const debug = props.debug || false;
|
|
// console.log("lazyHeight", lazyHeight);
|
|
// console.log("lazyHeight", lazyHeight);
|
|
return (
|
|
return (
|
|
<LazyLoad height={lazyHeight} offset={1e4}>
|
|
<LazyLoad height={lazyHeight} offset={1e4}>
|
|
- <ViewerInner {...props}>{allChildren}</ViewerInner>
|
|
|
|
|
|
+ <ViewerInner {...props} debug={debug}>
|
|
|
|
+ {allChildren}
|
|
|
|
+ </ViewerInner>
|
|
</LazyLoad>
|
|
</LazyLoad>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -44,6 +43,7 @@ Viewer.propTypes = {
|
|
pause: PropTypes.object,
|
|
pause: PropTypes.object,
|
|
children: PropTypes.any,
|
|
children: PropTypes.any,
|
|
debug: PropTypes.bool,
|
|
debug: PropTypes.bool,
|
|
|
|
+ scrollSpeed: PropTypes.number,
|
|
};
|
|
};
|
|
|
|
|
|
class ViewerInner extends Component {
|
|
class ViewerInner extends Component {
|
|
@@ -91,6 +91,11 @@ class ViewerInner extends Component {
|
|
this.timeline.kill(true);
|
|
this.timeline.kill(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ componentDidUpdate() {
|
|
|
|
+ if (this.props.debug) {
|
|
|
|
+ this.timeline.scrollTrigger.refresh();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
this.fullFrameCount = this.props.frameCount;
|
|
this.fullFrameCount = this.props.frameCount;
|
|
@@ -198,7 +203,7 @@ class ViewerInner extends Component {
|
|
start: "top top",
|
|
start: "top top",
|
|
end: "bottom bottom",
|
|
end: "bottom bottom",
|
|
ease: "none",
|
|
ease: "none",
|
|
- markers: isDebug,
|
|
|
|
|
|
+ markers: this.props.debug || false,
|
|
onUpdate: (trigger) => {
|
|
onUpdate: (trigger) => {
|
|
//处理processloading
|
|
//处理processloading
|
|
if (!this.lastProgress) {
|
|
if (!this.lastProgress) {
|
|
@@ -256,7 +261,7 @@ class ViewerInner extends Component {
|
|
initializeEnterTween() {
|
|
initializeEnterTween() {
|
|
const duration = this.props.enterTween.duration || 1;
|
|
const duration = this.props.enterTween.duration || 1;
|
|
let openPin = false;
|
|
let openPin = false;
|
|
- console.warn("this.props.enterTween", duration, this.props.enterTween);
|
|
|
|
|
|
+ // console.warn("this.props.enterTween", duration, this.props.enterTween);
|
|
gsap.set(this.viewerRef.current, {
|
|
gsap.set(this.viewerRef.current, {
|
|
yPercent: -100 * duration,
|
|
yPercent: -100 * duration,
|
|
});
|
|
});
|