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

add new feature "input nilai rotasi bagian rotate teks" #44

Merged
merged 8 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,12 @@
<input type="color" id="colorPicker" />
</div>

<div style="display: flex; align-items: center; margin: 20px 0px">
<label for="rotate" style="margin-right: 8px">Rotasi</label>
<input
type="range"
min="-180"
max="180"
step="1"
value="0"
id="rotate"
style="margin: 0 8px 0 0"
/>
<output id="rotate-val">0°</output>

<div style="display: flex; align-items: center; margin: 20px 0px;">
<label for="rotate" style="margin-right:8px">Rotasi</label>
<input type="range" min="-180" max="180" step="1" value="0" id="rotate" style="margin:0 8px 0 0">
<input type="text" size="1" id="rotate-input" value="0" >

</div>

<div style="display: flex; align-items: center; margin: 20px 0px">
Expand Down
21 changes: 16 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const downloadAnchor = document.querySelector('#download');
const elementOpacity = document.querySelector('#opacity');
const labelFile = document.querySelector('.label-file');
const elementRotate = document.querySelector('#rotate');
const elementInputRotate = document.querySelector('#rotate-input');
const closeBtn = document.querySelector('.close-btn');
const resetAnchor = document.querySelector('#reset');
const navBar = document.querySelector('.nav-bar');
Expand Down Expand Up @@ -108,6 +109,20 @@ window.addEventListener('DOMContentLoaded', () => {
draggable();
});

// bagian pengaturan rotasi teks
elementRotate.addEventListener('input', function () {
let rotVal = elementRotate.value;
document.getElementById('rotate-input').value = rotVal;
draggable(img);
});

elementInputRotate.addEventListener('input', function () {
let rotVal = elementInputRotate.value;
document.getElementById('rotate').value = rotVal;
draggable(img);
});
// bagian pengaturan rotasi teks

selectPosition.addEventListener('input', function () {
const position = selectPosition.value;

Expand Down Expand Up @@ -153,11 +168,6 @@ window.addEventListener('DOMContentLoaded', () => {
draggable(img);
});

elementRotate.addEventListener('input', function () {
draggable(img);
document.getElementById('rotate-val').innerHTML = elementRotate.value + '°';
});

canvas.addEventListener('click', function (e) {
selectedText = 1;
mouseXY(e);
Expand Down Expand Up @@ -349,6 +359,7 @@ function dispatchEvent(element, eventName) {
const event = document.createEvent('HTMLEvents');
event.initEvent(eventName, false, true);


element.dispatchEvent(event);
} else {
element.fireEvent(eventName); // only for backward compatibility (older browsers)
Expand Down