Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
this fixes #190
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Aug 30, 2014
1 parent 25ccc6b commit cf6d22c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions js/element-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ var divDialog = null;
var taCandidate = null;

var targetElements = [];
var svgWidth = 0;
var svgHeight = 0;

/******************************************************************************/

Expand Down Expand Up @@ -636,9 +638,22 @@ var onKeyPressed = function(ev) {

/******************************************************************************/

var onScrolled = function(ev) {
var newHeight = this.scrollY + this.innerHeight;
if ( newHeight > svgHeight ) {
svgHeight = newHeight;
svgRoot.setAttribute('height', svgHeight);
svgRoot.setAttribute("viewBox", '0 0 ' + svgWidth + ' ' + svgHeight);
}
highlightElements(targetElements, true);
};

/******************************************************************************/

var stopPicker = function() {
if ( pickerRoot !== null ) {
document.removeEventListener('keydown', onKeyPressed);
window.removeEventListener('scroll', onScrolled);
taCandidate.removeEventListener('input', onCandidateChanged);
divDialog.removeEventListener('click', onDialogClicked);
svgRoot.removeEventListener('mousemove', onSvgHovered);
Expand Down Expand Up @@ -790,8 +805,11 @@ var startPicker = function() {

svgRoot = document.createElementNS(svgns, 'svg');
svgRoot.innerHTML = '<path /><path />';
var svgWidth = document.documentElement.scrollWidth;
var svgHeight = document.documentElement.scrollHeight;
svgWidth = document.documentElement.scrollWidth;
svgHeight = Math.max(
document.documentElement.scrollHeight,
window.scrollY + window.innerHeight
);
svgRoot.setAttribute('x', 0);
svgRoot.setAttribute('y', 0);
svgRoot.setAttribute('width', svgWidth);
Expand Down Expand Up @@ -829,6 +847,7 @@ var startPicker = function() {
divDialog.addEventListener('click', onDialogClicked);
taCandidate = divDialog.querySelector('textarea');
taCandidate.addEventListener('input', onCandidateChanged);
window.addEventListener('scroll', onScrolled);
document.addEventListener('keydown', onKeyPressed);
};

Expand Down

0 comments on commit cf6d22c

Please sign in to comment.