dist/crocodoc.viewer.js
function () {
            var i, len, page, $page,
                width, height, left, top, paddingH,
                state = this.state,
                viewportWidth = state.viewportDimensions.clientWidth,
                viewportHeight = state.viewportDimensions.clientHeight;
            // update pages so they are centered (preserving margins)
            for (i = 0, len = this.$pages.length; i < len; ++i) {
                $page = this.$pages.eq(i);
                page = state.pages[i];

                if (this.twoPageMode) {
                    paddingH = (i % 2 === 1) ? page.paddingRight : page.paddingLeft;
                } else {
                    paddingH = page.paddingRight + page.paddingLeft;
                }
                width = (page.actualWidth + paddingH) * state.zoomState.zoom;
                height = (page.actualHeight + page.paddingTop + page.paddingBottom) * state.zoomState.zoom;

                if (this.twoPageMode) {
                    left = Math.max(0, (viewportWidth - width * 2) / 2);
                    if (i % 2 === 1) {
                        left += width;
                    }
                } else {
                    left = (viewportWidth - width) / 2;
                }
                top = (viewportHeight - height) / 2;
                left = Math.max(left, 0);
                top = Math.max(top, 0);
                $page.css({
                    marginLeft: left,
                    marginTop: top
                });
            }
        }
function () {
            var i, len, page, $page,
                width, height, left, top, paddingH,
                state = this.state,
                viewportWidth = state.viewportDimensions.clientWidth,
                viewportHeight = state.viewportDimensions.clientHeight;
            // update pages so they are centered (preserving margins)
            for (i = 0, len = this.$pages.length; i < len; ++i) {
                $page = this.$pages.eq(i);
                page = state.pages[i];

                if (this.twoPageMode) {
                    paddingH = (i % 2 === 1) ? page.paddingRight : page.paddingLeft;
                } else {
                    paddingH = page.paddingRight + page.paddingLeft;
                }
                width = (page.actualWidth + paddingH) * state.zoomState.zoom;
                height = (page.actualHeight + page.paddingTop + page.paddingBottom) * state.zoomState.zoom;

                if (this.twoPageMode) {
                    left = Math.max(0, (viewportWidth - width * 2) / 2);
                    if (i % 2 === 1) {
                        left += width;
                    }
                } else {
                    left = (viewportWidth - width) / 2;
                }
                top = (viewportHeight - height) / 2;
                left = Math.max(left, 0);
                top = Math.max(top, 0);
                $page.css({
                    marginLeft: left,
                    marginTop: top
                });
            }
        }
function ( ) { var i , len , page , $page , width , height , left , top , paddingH , state = this . state , viewportWidth = state . viewportDimensions . clientWidth , viewportHeight = state . viewportDimensions . clientHeight ; // update pages so they are centered (preserving margins) for ( i = 0 , len = this . $pages . length ; i < len ; ++ i ) { $page = this . $pages . eq ( i ) ; page = state . pages [ i ] ; if ( this . twoPageMode ) { paddingH = ( i % 2 === 1 ) ? page . paddingRight : page . paddingLeft ; } else { paddingH = page . paddingRight + page . paddingLeft ; } width = ( page . actualWidth + paddingH ) * state . zoomState . zoom ; height = ( page . actualHeight + page . paddingTop + page . paddingBottom ) * state . zoomState . zoom ; if ( this . twoPageMode ) { left = Math . max ( 0 , ( viewportWidth - width * 2 ) / 2 ) ; if ( i % 2 === 1 ) { left += width ; } } else { left = ( viewportWidth - width ) / 2 ; } top = ( viewportHeight - height ) / 2 ; left = Math . max ( left , 0 ) ; top = Math . max ( top , 0 ) ; $page . css ( { marginLeft : left , marginTop : top } ) ; } }
Update page margins for the viewport size and zoom level
@returns {void}
Update page margins for the viewport size and zoom level