Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow key support signing #1143

Merged
merged 5 commits into from
Apr 30, 2024
Merged

Conversation

t71rs
Copy link
Contributor

@t71rs t71rs commented Apr 29, 2024

Description

A signature can now also be moved with the arrow keys. Meaning if it is made so small that it can not be grabbed anymore to move it, the arrow keys still provide a drag functionality. This would be easy to implement for other uses cases as well (e.g. adding an image to a pdf), as of now it only works for the signing tool.
This is my first contribution, i am always happy about feedback :).

Closes #744

Checklist:

  • I have read the Contribution Guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Contributor License Agreement

By submitting this pull request, I acknowledge and agree that my contributions will be included in Stirling-PDF and that they can be relicensed in the future under the MPL 2.0 (Mozilla Public License Version 2.0) license.

(This does not change the general open-source nature of Stirling-PDF, simply moving from one license to another license)

@t71rs t71rs requested a review from Frooodle as a code owner April 29, 2024 19:55
const target = document.querySelector('.draggable-canvas');

// Define the step size for each key press
const step = 10; // Adjust step size as needed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like step should be based on the size of the block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, i will try and add that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have adjusted the code, it is now based on a percentage of the size of the Element.

],
inertia: true,
});
if(window.location.pathname.endsWith('sign')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: extend this to other features.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could any other features use this functionality? If not, we should move it into it's own thing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add-image could support this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it already works for add image if the if statement is left out, but if two images are added, both are moving. I will try and figure out a way so only one is moving.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extended this feature to add-Image. Arrow key support is enabled for an element as soon as it is added. By clicking or dragging a different element arrow key support is enabled for that element.

@sbplat sbplat merged commit d730c6a into Stirling-Tools:main Apr 30, 2024
3 checks passed
@sbplat
Copy link
Member

sbplat commented Apr 30, 2024

Thanks! This is going to save so many headaches. :)

@t71rs t71rs deleted the Arrow-key-support-signing branch May 3, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot move small signature
3 participants