Skip to content
Snippets Groups Projects
Commit 5979067e authored by Andreas Gohr's avatar Andreas Gohr
Browse files

reset scroll position when setting selection FS#1707

Ignore-this: cb035f32eccc0fcb2c9163b8620abb91

darcs-hash:20090603170042-7ad00-07ee60074714d6d23d34e59269776ccb504d1f0a.gz
parent a4b53097
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ function selection_class(){
this.end = 0;
this.obj = null;
this.rangeCopy = null;
this.scroll = 0;
this.getLength = function(){
return this.end - this.start;
......@@ -41,8 +42,9 @@ function getSelection(textArea) {
textArea.focus();
if(document.getSelection) { // Mozilla et al.
sel.start = textArea.selectionStart;
sel.end = textArea.selectionEnd;
sel.start = textArea.selectionStart;
sel.end = textArea.selectionEnd;
sel.scroll = textArea.scrollTop;
} else if(document.selection) { // MSIE
// The current selection
var range = document.selection.createRange();
......@@ -72,6 +74,7 @@ function setSelection(selection){
if(document.getSelection){ // FF
// what a pleasure in FF ;)
selection.obj.setSelectionRange(selection.start,selection.end);
if(selection.scroll) selection.obj.scrollTop = selection.scroll;
} else if(document.selection) { // IE
// count number of newlines in str to work around stupid IE selection bug
var countNL = function(str) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment