playground/assets/dflip/js/dflip.js
/**
         * Fixes text selection: adds additional div where mouse was clicked.
         * This reduces flickering of the content if mouse slowly dragged down/up.
         * @private
         */
Fixes text selection: adds additional div where mouse was clicked.
This reduces flickering of the content if mouse slowly dragged down/up.
@private
Fixes text selection : adds additional div where mouse was clicked . This reduces flickering of the content if mouse slowly dragged down / up . @private
function TextLayerBuilder_bindMouse() {
            var div = this.textLayerDiv;
            var self = this;
            div.addEventListener('mousedown', function (e) {
                if (self.enhanceTextSelection && self.textLayerRenderTask) {
                    self.textLayerRenderTask.expandTextDivs(true);
                    return;
                }
                var end = div.querySelector('.endOfContent');
                if (!end) {
                    return;
                }
                var adjustTop = e.target !== div;
                adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
                if (adjustTop) {
                    var divBounds = div.getBoundingClientRect();
                    var r = Math.max(0, (e.pageY - divBounds.top) / divBounds.height);
                    end.style.top = (r * 100).toFixed(2) + '%';
                }
                end.classList.add('active');
            });
            div.addEventListener('mouseup', function (e) {
                if (self.enhanceTextSelection && self.textLayerRenderTask) {
                    self.textLayerRenderTask.expandTextDivs(false);
                    return;
                }
                var end = div.querySelector('.endOfContent');
                if (!end) {
                    return;
                }
                end.style.top = '';
                end.classList.remove('active');
            });
        }
function TextLayerBuilder_bindMouse ( ) { var div = this . textLayerDiv ; var self = this ; div . addEventListener ( 'mousedown' , function ( e ) { if ( self . enhanceTextSelection && self . textLayerRenderTask ) { self . textLayerRenderTask . expandTextDivs ( true ) ; return ; } var end = div . querySelector ( '.endOfContent' ) ; if ( ! end ) { return ; } var adjustTop = e . target !== div ; adjustTop = adjustTop && window . getComputedStyle ( end ) . getPropertyValue ( '-moz-user-select' ) !== 'none' ; if ( adjustTop ) { var divBounds = div . getBoundingClientRect ( ) ; var r = Math . max ( 0 , ( e . pageY - divBounds . top ) / divBounds . height ) ; end . style . top = ( r * 100 ) . toFixed ( 2 ) + '%' ; } end . classList . add ( 'active' ) ; } ) ; div . addEventListener ( 'mouseup' , function ( e ) { if ( self . enhanceTextSelection && self . textLayerRenderTask ) { self . textLayerRenderTask . expandTextDivs ( false ) ; return ; } var end = div . querySelector ( '.endOfContent' ) ; if ( ! end ) { return ; } end . style . top = '' ; end . classList . remove ( 'active' ) ; } ) ; }
Fixes text selection: adds additional div where mouse was clicked.
Fixes text selection : adds additional div where mouse was clicked .
// On non-Firefox browsers, the selection will feel better if the height
 // of the endOfContent div will be adjusted to start at mouse click
 // location -- this will avoid flickering when selections moves up.
 // However it does not work when selection started on empty space.
