Turn.js more controls to make buttons

試著忘記壹切 提交于 2020-01-01 07:21:13

问题


I've been looking on ways on how to make controls/button to manipulate turn.js to make my own magazine web page.

here is my html script

<div id="magazine">
    <div style="background-image:url(pages/01.jpg);"></div>
    <div style="background-image:url(pages/02.jpg);"></div>
    <div style="background-image:url(pages/03.jpg);"></div>
    <div style="background-image:url(pages/04.jpg);"></div>
    <div style="background-image:url(pages/05.jpg);"></div>
    <div style="background-image:url(pages/06.jpg);"></div>
</div>

<a onclick="turntopage(4)">Go to page 4</a>

and i want to make some button controls like Go to page 4. here is the javascript

//initialize turn js
$(window).ready(function() {
    $('#magazine').turn({
        display: 'double',
        acceleration: true,
        gradients: !$.isTouch,
        elevation:50,
        when: {
            turned: function(e, page) {
                /*console.log('Current view: ', $(this).turn('view'));*/
            }
        }
    });
});

there is already way to do some next and previous controls

$(window).bind('keydown', function(e){
    if (e.keyCode==37)
        $('#magazine').turn('previous');
    else if (e.keyCode==39)
        $('#magazine').turn('next');
});

and i want to make controls for go to where ever page i want to go. is there a way i can do this?


回答1:


There is method for that

$("#magazine").turn("page",4)  // goto page number 4

http://www.turnjs.com/#samples/docs/18



来源:https://stackoverflow.com/questions/13027185/turn-js-more-controls-to-make-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!