Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In pdf.js how do I turn on handtool as the default setting?

Tags:

pdf.js

I am using pdf.js to display a pdf. I would like the handtool to be on as the default setting, rather than people having to access it via clicking on the button.

This is the html button code:

  <button id="toggleHandTool" class="secondaryToolbarButton handTool" title="Enable hand tool" tabindex="27" data-l10n-id="hand_tool_enable">
              <span data-l10n-id="hand_tool_enable_label">Enable hand tool</span>
            </button>

This is the code on the .js document:

    var HandTool = {
  initialize: function handToolInitialize(options) {
    var toggleHandTool = options.toggleHandTool;
    this.handTool = new GrabToPan({
      element: options.container,
      onActiveChanged: function(isActive) {
        if (!toggleHandTool) {
          return;
        }
        if (isActive) {
          toggleHandTool.title =
            mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
          toggleHandTool.firstElementChild.textContent =
            mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
        } else {
          toggleHandTool.title =
            mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
          toggleHandTool.firstElementChild.textContent =
            mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
        }
      }
    });
    if (toggleHandTool) {
      toggleHandTool.addEventListener('click', this.toggle.bind(this), false);
    }

toggle: function handToolToggle() {
this.handTool.toggle();
SecondaryToolbar.close();
 },

Can I add something to my html to turn that on immediately after page load? Or can I change the .js file to do that?

like image 282
user3330508 Avatar asked Dec 08 '22 09:12

user3330508


2 Answers

I was just trying to achieve the same thing.

Apparently it's as simple as changing enableHandToolOnLoad: false to enableHandToolOnLoad: true in viewer.js.

Probably this wasn't possible at the time you've posted this question.

like image 107
TheLostOne Avatar answered Feb 24 '23 03:02

TheLostOne


OK I worked it out.....

I added:

<body onLoad="HandTool.toggle()">

to the end of the html, just before

</body>
like image 27
user3330508 Avatar answered Feb 24 '23 02:02

user3330508