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?
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.
OK I worked it out.....
I added:
<body onLoad="HandTool.toggle()">
to the end of the html, just before
</body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With