Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Fixes Page Scroll Issue #87

Merged
merged 6 commits into from
Sep 1, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed: Copy selection
CaptainDredge committed Aug 25, 2020
commit b7281e8566565ab054257e3be712fa5199726e9c
18 changes: 18 additions & 0 deletions js/app.mjs
Original file line number Diff line number Diff line change
@@ -28,6 +28,11 @@ const pageEl = document.querySelector('.page-a');

const setTextareaStyle = (attrib, v) => (pageEl.style[attrib] = v);

// eslint-disable-next-line no-var
var ctrlDown = false;
const ctrlKey = 17;
const cmdKey = 91;

/**
* Add event listeners here, they will be automatically mapped with addEventListener later
*/
@@ -127,6 +132,19 @@ const EVENT_MAP = {
};

const DELEGATED_EVENT_MAP = [
{
on: 'keydown',
action: (e) => {
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = true;
}
},
{
on: 'keyup',
action: (e) => {
// eslint-disable-next-line no-unused-vars
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = false;
}
},
{
on: 'paste',
action: formatText
3 changes: 3 additions & 0 deletions js/utils/helpers.mjs
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ const fixedPage = document.querySelector(
'.display-flex.left-margin-and-content'
);
const fixedHeight = fixedPage.clientHeight;
const vKey = 86;
const cKey = 67;
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);

function addFontFromFile(fileObj) {
@@ -125,6 +127,7 @@ function adjustContent(remainingContent = '') {
}

function trimContent(event) {
if (ctrlDown && (event.keyCode == vKey || event.keyCode == cKey)) return;
if (String.fromCharCode(event.keyCode).match(/(\w|\s|\n|\r|\t)/g))
adjustContent.call(this);
}