Reputation: 177
Right now , i need to do page flip animation in react . I saw turn.js library which is used for page flip . I imported that in the react component . It is not calling the Jquery function(.turn) in that library
Import statement
import React from 'react';
import $ from 'jquery'
import 'turn.js/index.js'
Oncomponent did mount method :
componentDidMount(){
$("#flipbook").turn({
width: 400,
height: 300,
autoCenter: true
});
}
On render :
<div>
<div ref="flipbook">
<div className="hard"> Turn.js </div>
<div className="hard"></div>
<div> Page 1 </div>
<div> Page 2 </div>
<div> Page 3 </div>
<div> Page 4 </div>
<div className="hard"></div>
<div className="hard"></div>
</div>
</div>
Error in browsers console :
Turn.js?36f0:16 Uncaught TypeError: jquery__WEBPACK_IMPORTED_MODULE_1___default(...)(...).turn is not a function
Upvotes: 1
Views: 1912
Reputation: 3389
Why don't you use react-flip-page. Its good and also responsive.
Install it using npm:
npm install --save react-flip-page
Then you can use FlipPage
as a component. Just like this:
<FlipPage>
<article>
<h1>My awesome first article</h1>
<p>My awesome first content</p>
</article>
<article>
<h1>My wonderful second article</h1>
<p>My wonderful second content</p>
</article>
<article>
<h1>My excellent third article</h1>
<p>My excellent third content</p>
</article>
</FlipPage>
Upvotes: 1