【发布时间】:2017-11-22 21:03:25
【问题描述】:
我有一个 react 项目,我想将 scrollmagic 与速度插件一起使用。一旦我已经设置了一个反应项目,这就是我从终端所做的事情
npm install scrollmagic
npm install velocity-react
这就是我的src/App.js 的样子
import React, { Component } from 'react';
import ScrollMagic from 'scrollmagic';
import Velocity from 'velocity-react';
class App extends Component {
componentDidMount() {
// init controller
var controller = new ScrollMagic.Controller();
// build scene
var scene = new ScrollMagic.Scene({triggerElement: "#trigger"})
// trigger a velocity opaticy animation
.setVelocity("#animate", {opacity: 0}, {duration: 400})
.addIndicators() // add indicators (requires plugin)
.addTo(controller);
}
render() {
return (
<div>
<div className="spacer s2"></div>
<div className="spacer s2"></div>
<div id="trigger" className="spacer s0"></div>
<div id="animate" className="box1 blue">
<p>Now you see me...</p>
<a href="#" className="viewsource">view source</a>
</div>
<div className="spacer s2"></div>
</div>
);
}
}
export default App;
然后我运行我的webpack 命令没有错误。现在,当我查看 Chrome 浏览器时,我看到一个空白页面。调试控制台给了我这些错误:
15:56:08:694 (ScrollMagic.Scene) -> 错误调用 setVelocity() 由于 缺少插件'animation.velocity'。请确保包括 插件/动画.velocity.js
15:56:08:694 (ScrollMagic.Scene) -> 调用 addIndicators() 时出错 缺少插件'debug.addIndicators'。请确保包括 插件/debug.addIndicators.js
如何让这些 Velocity 和 Indicator 函数在 reactjs 环境中与 scrollmagic 一起使用?
【问题讨论】:
标签: reactjs scrollmagic