最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add next and previous button --- Turn.js - Stack Overflow

programmeradmin0浏览0评论

Created a demo of flipbook using turn.js which is working fine if I tap on the corners.

I need to add the next and previous button which is a feature of turns js, but am unable to add it.

Can anyone help me out.

JS:

$("#flipbook").turn({
    width: 400,
    height: 300,
    autoCenter: true,
    next:true
});

demo Link

Created a demo of flipbook using turn.js which is working fine if I tap on the corners.

I need to add the next and previous button which is a feature of turns js, but am unable to add it.

Can anyone help me out.

JS:

$("#flipbook").turn({
    width: 400,
    height: 300,
    autoCenter: true,
    next:true
});

demo Link

Share Improve this question asked Sep 12, 2014 at 4:11 user1853128user1853128 1,1147 gold badges20 silver badges46 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

jQuery Turn library supports methods to explicitly turn the page.

To fulfill your requirement, we can add two buttons, bind click events on them and call the Turn library methods (named "next" and "previous") respectively.

Check this working demo.

HTML (adding two buttons):

<div class="flip-control">
    <a href="#" id="prev"> Previous </a>
    <a href="#" id="next"> Next </a>
</div>

CSS (applying styles) :

div.flip-control {
    width: 400px;
    text-align: center;
}

div.flip-control a {
    margin-left: 10px;
}

JavaScript :

var oTurn = $("#flipbook").turn({
    width: 400,
    height: 300,
    autoCenter: true,
    next:true
});

$("#prev").click(function(e){
    e.preventDefault();
    oTurn.turn("previous");
});

$("#next").click(function(e){
    e.preventDefault();
    oTurn.turn("next");
});
$('.sj-book').turn('previous');

OR

$('.sj-book').turn('next');

And You will be happy!

Happy New Year!
С новым годом!

发布评论

评论列表(0)

  1. 暂无评论