首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更改turnjs页面的高度

如何更改turnjs页面的高度
EN

Stack Overflow用户
提问于 2015-10-30 16:51:47
回答 4查看 3.5K关注 0票数 1

这里我使用的是turn js翻转库,我想改变turn js页面的高度。这里使用客户端高度来计算页面的高度。现在我需要将页面的高度更改为700px。我该怎么做呢?

代码语言:javascript
复制
<script type='text/javascript'>
    (function () {
        'use strict';
        var module = {
            ratio: 1.38,
            init: function (id) {
                var me = this;
                if (document.addEventListener) {
                    this.el = document.getElementById(id);
                    this.resize();
                    this.plugins();
                    window.addEventListener('resize', function (e) {
                        var size = me.resize();
                        $(me.el).turn('size', size.width, size.height);
                    });
                }
            },
            resize: function () {
                this.el.style.width = '';
                this.el.style.height = '';
                var width = this.el.clientWidth,
                height = Math.round(width / this.ratio),
                padded = Math.round(document.body.clientHeight * 0.9);  
                if (height > padded) {
                    height = padded;
                    width = Math.round(height * this.ratio);
                }
                this.el.style.width = width + 'px';
                this.el.style.height = height + 'px';
                return {
                    width: width,
                    height: height
                };
            },
            plugins: function () {
                $(this.el).turn({
                    gradients: true,
                    acceleration: true
                });
                document.body.className = 'hide-overflow';
            }
        };
        module.init('book');
    }());
</script>

html:

代码语言:javascript
复制
<div class="t">
    <div class="tc rel">
        <div class="book" id="book">    
            <div class="page page1">
                <img src="image600x650.png">
            </div>
        </div>
    </div>
</div>
EN

回答 4

Stack Overflow用户

发布于 2015-10-30 17:19:06

您已经拥有了website上的所有信息。你必须这样做:

代码语言:javascript
复制
$("flipbook").height(700);
票数 2
EN

Stack Overflow用户

发布于 2017-08-19 18:14:45

下面是料盒高度500px和宽度992px函数loadApp() {)的代码

代码语言:javascript
复制
    flipbook.turn({

        // Magazine width

        width: 922,

        // Magazine height
        // Modify below height as you need

        height: 500,

    }

});

并根据需要修改magazine.css / add样式,如下所示设置高度

代码语言:javascript
复制
.magazine-viewport .container{
    width:922px;
    height:500px;
}

.magazine-viewport .magazine{
    width:922px;
    height:500px;
}

 .magazine-viewport .page{
    width:922px;
    height:500px;
}
.magazine-viewport .next-button,
.magazine-viewport .previous-button{
    width:22px;
    height:500px;
}
票数 2
EN

Stack Overflow用户

发布于 2016-01-06 23:58:21

在main.js中

代码语言:javascript
复制
function loadApp() {

$('#canvas').fadeIn(1000);

var flipbook = $('.magazine');

// Check if the CSS was already loaded

if (flipbook.width()==0 || flipbook.height()==0) {
    setTimeout(loadApp, 10);
    return;
}

// Create the flipbook

flipbook.turn({

        // Magazine width

        // width: 922,
        width: 1245,

        // Magazine height

        // height: 600,
        height: 810,

        // Duration in millisecond

        duration: 1000,

        // Hardware acceleration

        acceleration: !isChrome(),

        // Enables gradients

        gradients: true,

        // Auto center this flipbook

        autoCenter: true,

        // Elevation from the edge of the flipbook when turning a page

        elevation: 50,

        // The number of pages

        pages: 12,

        // Events

        when: {
            turning: function(event, page, view) {

                var book = $(this),
                currentPage = book.turn('page'),
                pages = book.turn('pages');

                // Update the current URI

                Hash.go('page/' + page).update();

                // Show and hide navigation buttons

                disableControls(page);


                $('.thumbnails .page-'+currentPage).
                    parent().
                    removeClass('current');

                $('.thumbnails .page-'+page).
                    parent().
                    addClass('current');



            },

            turned: function(event, page, view) {

                disableControls(page);

                $(this).turn('center');

                if (page==1) { 
                    $(this).turn('peel', 'br');
                }

            },

            missing: function (event, pages) {

                // Add pages that aren't in the magazine

                for (var i = 0; i < pages.length; i++)
                    addPage(pages[i], $(this));

            }
        }

});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33431969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档