From 6efc0b165206b6f7c926aaa574057c060b88cf41 Mon Sep 17 00:00:00 2001 From: Arnau Sanchez Date: Tue, 24 Mar 2015 12:00:19 +0100 Subject: [PATCH 1/4] Follow scroll on clone element --- src/tabcomplete.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tabcomplete.js b/src/tabcomplete.js index b3f414f..6c5a806 100644 --- a/src/tabcomplete.js +++ b/src/tabcomplete.js @@ -197,6 +197,15 @@ ); } + + // Propagate scroll events from element to element . + function follow_scroll(source, destination) { + source.scroll(function() { + destination.scrollTop(source.scrollTop()); + destination.scrollLeft(source.scrollLeft()); + }); + } + // Show placeholder text. // This works by creating a copy of the input and placing it behind // the real input. @@ -226,6 +235,7 @@ clone.css({ position: "absolute", }); + follow_scroll(input, clone); } var hint = ""; From 1780fd497ddf1cfee4e3d79c835f12a546e18d05 Mon Sep 17 00:00:00 2001 From: Arnau Sanchez Date: Tue, 14 Apr 2015 14:23:15 +0200 Subject: [PATCH 2/4] follow_scroll: bind also change event --- src/tabcomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabcomplete.js b/src/tabcomplete.js index 6c5a806..4aed70f 100644 --- a/src/tabcomplete.js +++ b/src/tabcomplete.js @@ -200,7 +200,7 @@ // Propagate scroll events from element to element . function follow_scroll(source, destination) { - source.scroll(function() { + source.bind("scroll change", function() { destination.scrollTop(source.scrollTop()); destination.scrollLeft(source.scrollLeft()); }); From d6fbb1e6187c2134ab50f047343b5af9edf8f745 Mon Sep 17 00:00:00 2001 From: Arnau Sanchez Date: Mon, 20 Apr 2015 14:19:58 +0200 Subject: [PATCH 3/4] bind also input on textarea --- src/tabcomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabcomplete.js b/src/tabcomplete.js index 4aed70f..9133c22 100644 --- a/src/tabcomplete.js +++ b/src/tabcomplete.js @@ -200,7 +200,7 @@ // Propagate scroll events from element to element . function follow_scroll(source, destination) { - source.bind("scroll change", function() { + source.bind("scroll input change", function() { destination.scrollTop(source.scrollTop()); destination.scrollLeft(source.scrollLeft()); }); From 19558d69230417c0c14a14348bac4480ffab3b2d Mon Sep 17 00:00:00 2001 From: Arnau Sanchez Date: Thu, 17 Sep 2015 09:39:23 +0200 Subject: [PATCH 4/4] add event for input[text] --- src/tabcomplete.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tabcomplete.js b/src/tabcomplete.js index 9133c22..7978185 100644 --- a/src/tabcomplete.js +++ b/src/tabcomplete.js @@ -200,9 +200,11 @@ // Propagate scroll events from element to element . function follow_scroll(source, destination) { - source.bind("scroll input change", function() { - destination.scrollTop(source.scrollTop()); - destination.scrollLeft(source.scrollLeft()); + source.bind("input keydown keyup focus blur click change scroll", function() { + setTimeout(function() { + destination.scrollTop(source.scrollTop()); + destination.scrollLeft(source.scrollLeft()); + }, 0); }); }