lib/scripts/screenshot.js
function (needsStitching) {

        var initData = {
                viewPort: {},
                document: {},
                bodyTransform: {}
            },

            de = document.documentElement,
            el = document.createElement('div'),
            body = document.body;

        // Get current scroll-position
        initData.viewPort.x = window.pageXOffset || body.scrollLeft || de.scrollLeft;
        initData.viewPort.y = window.pageYOffset || body.scrollTop || de.scrollTop;

        // Get current view-port size
        el.style.position = "fixed";
        el.style.top = 0;
        el.style.left = 0;
        el.style.bottom = 0;
        el.style.right = 0;
        de.insertBefore(el, de.firstChild);
        initData.viewPort.width = el.offsetWidth;
        initData.viewPort.height = el.offsetHeight;
        de.removeChild(el);
        //initData.viewPort.width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
        //initData.viewPort.height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);

        // Get document size & state of scrollbar styles
        initData.document.width = Math.max(body.scrollWidth, body.offsetWidth, de.clientWidth, de.scrollWidth, de.offsetWidth);
        initData.document.height = Math.max(body.scrollHeight, body.offsetHeight, de.clientHeight, de.scrollHeight, de.offsetHeight);
        initData.document.cssHeight = body.style.height;
        initData.document.overflow = body.style.overflow;

        // See which transformation property to use and what value it has
        // Needed for scroll-translation without the page actually knowing about it
        if (body.style.webkitTransform !== undefined) {
            initData.bodyTransform.property = 'webkitTransform';
        } else if (body.style.mozTransform !== undefined) {
            initData.bodyTransform.property = 'mozTransform';
        } else if (body.style.msTransform !== undefined) {
            initData.bodyTransform.property = 'msTransform';
        } else if (body.style.oTransform !== undefined) {
            initData.bodyTransform.property = 'oTransform';
        } else {
            initData.bodyTransform.property = 'transform';
        }
        initData.bodyTransform.value = body.style[initData.bodyTransform.property];
		initData.needsStitching = needsStitching;

        // Change document

        // Reset scrolling through translate
		if (needsStitching) {
			body.style[initData.bodyTransform.property] = 'translate(' + initData.viewPort.x + 'px, ' + initData.viewPort.y + 'px)';
		}

        return JSON.stringify(initData);
    }
function (needsStitching) {

        var initData = {
                viewPort: {},
                document: {},
                bodyTransform: {}
            },

            de = document.documentElement,
            el = document.createElement('div'),
            body = document.body;

        // Get current scroll-position
        initData.viewPort.x = window.pageXOffset || body.scrollLeft || de.scrollLeft;
        initData.viewPort.y = window.pageYOffset || body.scrollTop || de.scrollTop;

        // Get current view-port size
        el.style.position = "fixed";
        el.style.top = 0;
        el.style.left = 0;
        el.style.bottom = 0;
        el.style.right = 0;
        de.insertBefore(el, de.firstChild);
        initData.viewPort.width = el.offsetWidth;
        initData.viewPort.height = el.offsetHeight;
        de.removeChild(el);
        //initData.viewPort.width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
        //initData.viewPort.height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);

        // Get document size & state of scrollbar styles
        initData.document.width = Math.max(body.scrollWidth, body.offsetWidth, de.clientWidth, de.scrollWidth, de.offsetWidth);
        initData.document.height = Math.max(body.scrollHeight, body.offsetHeight, de.clientHeight, de.scrollHeight, de.offsetHeight);
        initData.document.cssHeight = body.style.height;
        initData.document.overflow = body.style.overflow;

        // See which transformation property to use and what value it has
        // Needed for scroll-translation without the page actually knowing about it
        if (body.style.webkitTransform !== undefined) {
            initData.bodyTransform.property = 'webkitTransform';
        } else if (body.style.mozTransform !== undefined) {
            initData.bodyTransform.property = 'mozTransform';
        } else if (body.style.msTransform !== undefined) {
            initData.bodyTransform.property = 'msTransform';
        } else if (body.style.oTransform !== undefined) {
            initData.bodyTransform.property = 'oTransform';
        } else {
            initData.bodyTransform.property = 'transform';
        }
        initData.bodyTransform.value = body.style[initData.bodyTransform.property];
		initData.needsStitching = needsStitching;

        // Change document

        // Reset scrolling through translate
		if (needsStitching) {
			body.style[initData.bodyTransform.property] = 'translate(' + initData.viewPort.x + 'px, ' + initData.viewPort.y + 'px)';
		}

        return JSON.stringify(initData);
    }
function ( needsStitching ) { var initData = { viewPort : { } , document : { } , bodyTransform : { } } , de = document . documentElement , el = document . createElement ( 'div' ) , body = document . body ; // Get current scroll-position initData . viewPort . x = window . pageXOffset || body . scrollLeft || de . scrollLeft ; initData . viewPort . y = window . pageYOffset || body . scrollTop || de . scrollTop ; // Get current view-port size el . style . position = "fixed" ; el . style . top = 0 ; el . style . left = 0 ; el . style . bottom = 0 ; el . style . right = 0 ; de . insertBefore ( el , de . firstChild ) ; initData . viewPort . width = el . offsetWidth ; initData . viewPort . height = el . offsetHeight ; de . removeChild ( el ) ; //initData.viewPort.width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); //initData.viewPort.height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); // Get document size & state of scrollbar styles initData . document . width = Math . max ( body . scrollWidth , body . offsetWidth , de . clientWidth , de . scrollWidth , de . offsetWidth ) ; initData . document . height = Math . max ( body . scrollHeight , body . offsetHeight , de . clientHeight , de . scrollHeight , de . offsetHeight ) ; initData . document . cssHeight = body . style . height ; initData . document . overflow = body . style . overflow ; // See which transformation property to use and what value it has // Needed for scroll-translation without the page actually knowing about it if ( body . style . webkitTransform !== undefined ) { initData . bodyTransform . property = 'webkitTransform' ; } else if ( body . style . mozTransform !== undefined ) { initData . bodyTransform . property = 'mozTransform' ; } else if ( body . style . msTransform !== undefined ) { initData . bodyTransform . property = 'msTransform' ; } else if ( body . style . oTransform !== undefined ) { initData . bodyTransform . property = 'oTransform' ; } else { initData . bodyTransform . property = 'transform' ; } initData . bodyTransform . value = body . style [ initData . bodyTransform . property ] ; initData . needsStitching = needsStitching ; // Change document // Reset scrolling through translate if ( needsStitching ) { body . style [ initData . bodyTransform . property ] = 'translate(' + initData . viewPort . x + 'px, ' + initData . viewPort . y + 'px)' ; } return JSON . stringify ( initData ) ; }
Initializes screenshots and gathers data to revert changes.
This function will also gather information required for
screenshots like dimensions of document and view-port.

@method init
@param {boolean} needsStitching
Initializes screenshots and gathers data to revert changes . This function will also gather information required for screenshots like dimensions of document and view - port .