Skip to content

Commit

Permalink
Merge pull request #1 from Submitty/eraser
Browse files Browse the repository at this point in the history
Eraser
  • Loading branch information
Victor Nazzaro authored Jul 29, 2018
2 parents 5410900 + dfcaa80 commit 1b1a319
Show file tree
Hide file tree
Showing 9 changed files with 773 additions and 722 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ node_modules/
coverage/
sandbox/shared
web/shared
dist
web-dist
npm-debug.log
74 changes: 62 additions & 12 deletions dist/pdf-annotate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/pdf-annotate.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/pdf-annotate.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/pdf-annotate.min.js.map

Large diffs are not rendered by default.

86 changes: 43 additions & 43 deletions src/UI/eraser.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import PDFJSAnnotate from '../PDFJSAnnotate';
import {
findAnnotationAtPoint,
findSVGAtPoint
} from './utils';

let _canerase = false;

function handleDocumentMouseDown(e){
_canerase = true;
}

function handleDocumentMouseUp(e){
_canerase = false;
}

function handleDocumentMouseMove(e){
if(_canerase){
let target = findAnnotationAtPoint(e.clientX, e.clientY);
if(target){
console.log(target);
let annotationId = target.getAttribute('data-pdf-annotate-id');
// let nodes = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`);
// let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());
// let { documentId } = getMetadata(svg);

// [...nodes].forEach((n) => {
// n.parentNode.removeChild(n);
// });

// PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId);
}
}
}

export function enableEraser(){
document.addEventListener('mousemove', handleDocumentMouseMove);
document.addEventListener('mousedown', handleDocumentMouseDown);
document.addEventListener('mouseup', handleDocumentMouseUp);
}

export function disableEraser(){
document.removeEventListener('mousemove', handleDocumentMouseMove);
import PDFJSAnnotate from '../PDFJSAnnotate';
import {
findAnnotationAtPoint,
findSVGAtPoint
} from './utils';

let _canerase = false;

function handleDocumentMouseDown(e){
_canerase = true;
}

function handleDocumentMouseUp(e){
_canerase = false;
}

function handleDocumentMouseMove(e){
if(_canerase){
let target = findAnnotationAtPoint(e.clientX, e.clientY);
if(target){
console.log(target);
let annotationId = target.getAttribute('data-pdf-annotate-id');
// let nodes = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`);
// let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());
// let { documentId } = getMetadata(svg);

// [...nodes].forEach((n) => {
// n.parentNode.removeChild(n);
// });

// PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId);
}
}
}

export function enableEraser(){
document.addEventListener('mousemove', handleDocumentMouseMove);
document.addEventListener('mousedown', handleDocumentMouseDown);
document.addEventListener('mouseup', handleDocumentMouseUp);
}

export function disableEraser(){
document.removeEventListener('mousemove', handleDocumentMouseMove);
}
46 changes: 23 additions & 23 deletions src/UI/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { addEventListener, removeEventListener, fireEvent } from './event';
import { disableEdit, enableEdit } from './edit';
import { disablePen, enablePen, setPen } from './pen';
import { enableEraser, disableEraser } from './eraser';
import { disableArrow, enableArrow, setArrow } from './arrow';
import { disablePoint, enablePoint } from './point';
import { disableRect, enableRect } from './rect';
import { disableCircle, enableCircle, setCircle, addCircle } from './circle';
import { disableText, enableText, setText } from './text';
import { createPage, renderPage } from './page';

export default {
addEventListener, removeEventListener, fireEvent,
disableEdit, enableEdit,
disablePen, enablePen, setPen,
enableEraser, disableEraser,
disablePoint, enablePoint,
disableRect, enableRect,
disableCircle, enableCircle, setCircle, addCircle,
disableArrow, enableArrow, setArrow,
disableText, enableText, setText,
createPage, renderPage
};
import { addEventListener, removeEventListener, fireEvent } from './event';
import { disableEdit, enableEdit } from './edit';
import { disablePen, enablePen, setPen } from './pen';
import { enableEraser, disableEraser } from './eraser';
import { disableArrow, enableArrow, setArrow } from './arrow';
import { disablePoint, enablePoint } from './point';
import { disableRect, enableRect } from './rect';
import { disableCircle, enableCircle, setCircle, addCircle } from './circle';
import { disableText, enableText, setText } from './text';
import { createPage, renderPage } from './page';

export default {
addEventListener, removeEventListener, fireEvent,
disableEdit, enableEdit,
disablePen, enablePen, setPen,
enableEraser, disableEraser,
disablePoint, enablePoint,
disableRect, enableRect,
disableCircle, enableCircle, setCircle, addCircle,
disableArrow, enableArrow, setArrow,
disableText, enableText, setText,
createPage, renderPage
};
Loading

0 comments on commit 1b1a319

Please sign in to comment.