Hack to fix scrolling
Essentially doing a setTimeout() to prevent feedback loops. This seems to work fine on Firefox, and has less side effect on Chrome than the previous hack. Change-Id: I2a8d7b910edbbd757479d7b0917c42f0c2155246
This commit is contained in:
@@ -39,6 +39,7 @@ import com.google.gwt.core.client.JavaScriptObject;
|
|||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.core.client.JsArrayString;
|
import com.google.gwt.core.client.JsArrayString;
|
||||||
import com.google.gwt.core.client.Scheduler;
|
import com.google.gwt.core.client.Scheduler;
|
||||||
|
import com.google.gwt.core.client.Scheduler.RepeatingCommand;
|
||||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
import com.google.gwt.dom.client.Element;
|
import com.google.gwt.dom.client.Element;
|
||||||
import com.google.gwt.dom.client.Style.Unit;
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
@@ -77,7 +78,7 @@ public class SideBySide2 extends Screen {
|
|||||||
interface Binder extends UiBinder<HTMLPanel, SideBySide2> {}
|
interface Binder extends UiBinder<HTMLPanel, SideBySide2> {}
|
||||||
private static Binder uiBinder = GWT.create(Binder.class);
|
private static Binder uiBinder = GWT.create(Binder.class);
|
||||||
|
|
||||||
private static final int HEADER_FOOTER = 60 + 15 * 2 + 38 + 26 * 2;
|
private static final int HEADER_FOOTER = 60 + 15 * 2 + 16 + 26 * 2;
|
||||||
private static final JsArrayString EMPTY =
|
private static final JsArrayString EMPTY =
|
||||||
JavaScriptObject.createArray().cast();
|
JavaScriptObject.createArray().cast();
|
||||||
|
|
||||||
@@ -705,18 +706,19 @@ public class SideBySide2 extends Screen {
|
|||||||
final CodeMirror other = otherCm(cm);
|
final CodeMirror other = otherCm(cm);
|
||||||
return new Runnable() {
|
return new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
/**
|
// Hack to prevent feedback loop, Chrome seems fine but Firefox chokes.
|
||||||
* Prevent feedback loop, Chrome seems fine but Firefox chokes.
|
if (cm.isScrollSetByOther()) {
|
||||||
* However on Chrome this may cause scrolling to be out of sync
|
|
||||||
* if scrolled too fast.
|
|
||||||
*/
|
|
||||||
double now = (double) System.currentTimeMillis();
|
|
||||||
if (cm.getScrollSetBy() == other && cm.getScrollSetAt() + 30 > now) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
other.scrollToY(cm.getScrollInfo().getTop());
|
other.scrollToY(cm.getScrollInfo().getTop());
|
||||||
other.setScrollSetBy(cm);
|
other.setScrollSetByOther(true);
|
||||||
other.setScrollSetAt(now);
|
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
|
||||||
|
@Override
|
||||||
|
public boolean execute() {
|
||||||
|
other.setScrollSetByOther(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,20 +140,12 @@ public class CodeMirror extends JavaScriptObject {
|
|||||||
return this.getScrollInfo();
|
return this.getScrollInfo();
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
public final native CodeMirror getScrollSetBy() /*-{
|
public final native boolean isScrollSetByOther() /*-{
|
||||||
return this.state.scrollSetBy;
|
return this.state.scrollSetByOther == true;
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
public final native void setScrollSetBy(CodeMirror cm) /*-{
|
public final native void setScrollSetByOther(boolean setByOther) /*-{
|
||||||
this.state.scrollSetBy = cm;
|
this.state.scrollSetByOther = setByOther;
|
||||||
}-*/;
|
|
||||||
|
|
||||||
public final native double getScrollSetAt() /*-{
|
|
||||||
return this.state.scrollSetAt;
|
|
||||||
}-*/;
|
|
||||||
|
|
||||||
public final native void setScrollSetAt(double when) /*-{
|
|
||||||
this.state.scrollSetAt = when;
|
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
public final native void on(String event, Runnable thunk) /*-{
|
public final native void on(String event, Runnable thunk) /*-{
|
||||||
|
|||||||
Reference in New Issue
Block a user