Skip to content

Commit

Permalink
Merged in EPUB-132 (pull request #1)
Browse files Browse the repository at this point in the history
Removed jumping of marker while it's being moved
  • Loading branch information
Maciej Pieńkowski committed Aug 28, 2014
2 parents e6333ca + 60ab572 commit f98e07f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 23 deletions.
15 changes: 2 additions & 13 deletions demo/css/style.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
#debugging {
position: fixed;
top: 0;
left: 0;
pointer-events: none;
}

span.selection {
background-color: yellow;
}
span.marker {
display: inline-block;
background-color: rgb(71, 71, 71);
width: 2px;
width: 0;
height: 0.9em;
position: absolute;
margin-top: 2px;
Expand Down Expand Up @@ -40,15 +33,11 @@ span.marker:after {
font-family: sans-serif;
color: white;
font-size: 12px;
position: fixed;
position: absolute;
top: 0;
left: 50%;
margin: 3px 3px 3px -250px;
}
.touch_status {
display: inline-block;
}

* {
/*-webkit-user-select: none;*/
}
23 changes: 20 additions & 3 deletions dist/jquery.custom-selection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jquery-custom-selection - v0.1.2 - 2014-08-26 */
/*! jquery-custom-selection - v0.1.2 - 2014-08-27 */
(function($) {
// Default configuration
var settings, defaults = {
Expand Down Expand Up @@ -140,8 +140,11 @@
}

function getRangeBoundAt(element) {
var offset = Math.max(1, getIndexOfElement(element));
var offset = getIndexOfElement(element);
var anchor = element.parentNode;
if (element.nextSibling) {
offset += 1;
}
return [anchor, offset];
}

Expand Down Expand Up @@ -172,7 +175,10 @@
}

function getTouchedElementByPoint(touchPoint) {
return contextDocument.elementFromPoint(touchPoint.clientX, touchPoint.clientY);
hideMarkers();
var element = contextDocument.elementFromPoint(touchPoint.clientX, touchPoint.clientY);
showMarkers();
return element;
}

function createMarker(kind) {
Expand All @@ -181,6 +187,17 @@
return span;
}

function hideMarkers() {
var css = {visibility: 'hidden'};
$(startMarker).css(css);
$(endMarker).css(css);
}

function showMarkers() {
var css = {visibility: 'visible'};
$(startMarker).css(css);
$(endMarker).css(css);
}

// -- Extracting word under pointer

Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.custom-selection.min.js

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

Loading

0 comments on commit f98e07f

Please sign in to comment.