Where's the pan tool in version 3.0+?

76 views
Skip to first unread message

Justin Jung

unread,
Jul 13, 2017, 1:00:12 PM7/13/17
to PDFTron WebViewer
Q: Where's the pan tool in version 3.0+?

A: You may notice that we've merged AnnotationSelect/TextSelect/Pan altogether into one. The default behaviour in 3.0+ is the following:
1. Default tool is AnnotationSelect, and it automatically changes to TextSelect when the mouse is over texts.
2. If you hold down space bar in the default tool, it changes to Pan.

But we thought it is also a good idea to provide an option to bring the pan button in the UI! To do so, you could add the following to config.js:

$(document).on('viewerLoaded', function() {
 
// Set PanTool to be default tool mode
  readerControl
.defaultToolMode = readerControl.docViewer.getTool('Pan');


 
// Add PanTool button in tool bar
 
var panTool = $('<span data-toolmode="Pan" class="glyphicons customicons hand" data-i18n="[title]controlbar.pan"></span>');
  panTool
.click(function() {
    readerControl
.setToolMode('Pan');
 
});
  $
('#toolList').prepend(panTool);
  readerControl
.docViewer.on('toolModeUpdated', function(e, tool) {
   
if (tool instanceof Tools.PanTool) {
      $
('span[data-toolmode=AnnotationEdit]').removeClass('active');
      $
('span[data-toolmode=Pan]').addClass('active');
   
}
 
});


 
// Add PanTool button in context menu
 
var attach = context.attach;
  context
.attach = function(selector, data) {
   
if (_.isArray(data)) {
      data
.splice(1, 0, {
        text
: 'Pan',
        action
: function(e) {
          e
.preventDefault();
          readerControl
.setToolMode('Pan');
       
}
     
});
   
}
    attach
.call(this, selector, data);
 
}
});

Reply all
Reply to author
Forward
0 new messages