BoostIO / BoostNote-Legacy

This repository is outdated and new Boost Note app is available! We've launched a new Boost Note app which supports real-time collaborative writing. https://github.com/BoostIO/BoostNote-App
Other
17.07k stars 1.47k forks source link

Inconsistent autoscroll (jumps) in preview mode #2568

Open mahdikooshkbaghi opened 5 years ago

mahdikooshkbaghi commented 5 years ago

Current behavior

When I add some text at the end of my markdown file and hit enter the preview will jump to somewhere in the middle of the text. Scrolling back to the end of the preview window is working as expected, however, hitting enter will bring the preview again to the wrong position. I have put my Markdown text at the end of this issue as well.

Environment

My markdown file

Kuramoto Model

The model is consist of $N$ coupled oscillators, $\theta_i(t)$, with natural frequencies $\omega_i$ deduced from the distribution $g(\omega)$. $$\frac{d\theta_i}{dt}=\omegai+\Sigma{j=1}^N K_{ij}\sin(\theta_i-\theta_j)$$ Each oscillator tries to run independently at its own frequency while the coupling tends to synchronize it to all the others. By making a suitable choice of a rotating frame, $$\theta_i \rightarrow \thetai-\Omega t$$ in which $\Omega$ is the first moment of $g(\omega)$, we can transform the system to system of phase oscillators whose natural frequencies have zero mean. Many different models for the coupling matrix $K{ij}$ have been considered such as nearest-neighbor coupling, hierarchical coupling, random long-range coupling or even state dependent interactions.

Kuramoto model with mean-field coupling

For this model, synchronization is conveniently measured by an order parameter. In the limit of infinitely many oscillators, $N = \infty$, the modulus of the order parameter vanishes if the oscillators are out of synchrony, and it is positive in synchronized states.

The original analysis of synchronization by Kuramoto consider mean-field coupling, $K_{ij}=K/N>0$, where $K$ is coupling constant.

def Kuramoto_orig(t, theta, arg):
    omega, K, N = arg
    theta_t = theta[:,None]
    delta_theta = theta-theta_t
    dtheta = omega + (K/N)*np.sum(np.sin(delta_theta), axis=1)
    return dtheta

The complex valued order parameter can be defined as: $$re^{i\psi}=\frac{1}{N}\Sigma_{j=1}^N e^{i\theta_j}$$

For $N=500, K=6$: r_psi_sync.png

For $N=500, K=1$ r_psi_not_sync.png

# Original Kuramoto
# Fix random init state
np.random.seed(123)
# Network parameters
N = 500
K = 6
# time interval
t0 = 0
dt = 1e-3
tf = 5000*dt
# initial condition
theta_0 = np.random.uniform(0, 2.*np.pi, N)
# Natural frequency
omega = np.random.uniform(-np.pi, np.pi, N)
arg = [omega, K, N]
solver = ode(Kuramoto_orig)
solver.set_integrator('vode',
                       atol = 1e-8,
                       rtol = 1e-6)
solver.set_f_params(arg)
solver.set_initial_value(theta_0,t0)
tvals = []
x = []
i = 0
while solver.successful() and solver.t < tf:
    solver.integrate(solver.t+dt)
    tvals.append(solver.t)
    x.append(solver.y)
    i += 1 
x = np.asarray(x)
R, psi = order_parameter(x)

writing Here and press enter will bring the preview mode somewhere in between the text

ZeroX-DG commented 5 years ago

We'll look into this. Thank for reporting

IssueHuntBot commented 5 years ago

@boostio funded this issue with $7. See it on IssueHunt

officialgupta commented 5 years ago

Has any progress been made on this? It is impossible to see the preview while writing until it is fixed.

mahdikooshkbaghi commented 5 years ago

Has any progress been made on this? It is impossible to see the preview while writing until it is fixed.

As far as I can check the behavior is not changed. Writing at the end of the markdown file (file includes figures, math, code, ...) will cause a jump to somewhere in the middle of the preview.

officialgupta commented 5 years ago

For now I have just disabled the feature to autoscroll in the settings

joaocastro commented 5 years ago

Me and my colleagues have been trying on the last couple of weeks to fix this problem. We verified the maths that are applied to the preview mode and we have concluded that the problem is coming from the framework Electron, so it'll be hard to fix on this project. Probably a feature on Electron may be needed to get more information and display both sides correctly.

juicetin commented 5 years ago

Based on your findings, could you please open a ticket in the Electron project describing the problem and link it back here please :)

It currently makes Boostnote borderline unusable once a note goes past the page length, as every time I start a newline once the page scrolls, the page jumps to the top, and only when I start typing, does it jump back down to the bottom again.

fah commented 5 years ago

I am sorry to write only one remark: This problem causes the application to be virtually unusable when editing large pages.

Please, please, focus on a solution to this problem.

I appreciate all the hard work that has been done and I love this project. But unfortunately I can not help.

I can only say how important it is for the acceptance of this project to solve this problem.

I showed this project to some colleagues and they were thrilled. Later, when they came across this problem, they did not want to use it anymore. Also, the workaround, to stop the synchronization, does not help because you can not see the changes immediately. It disturbs the workflow.

Flexo013 commented 5 years ago

@fah Turning of scroll sync (autoscroll) should be a fine workaround for now. All you have to do is scroll in each window to the place where your edits are made. This should barely take any extra time unless you are jumping all around notes every minute.

Could you provide us with some extra info of the problem in your case? Is the autoscroll going too far or not far enough? Are you jumping to the start or end of a note when making edits? This info will hopefully help with fixing this issue.

fah commented 5 years ago

@Flexo013 Turning off sync is for me, as I write larger documents and run and jump between them, a headache. I'm more searching for the right spot on the preview then making progress in writing.

Especially for 4+ pages documents: Adding lines at the end, the preview jumps randomly from the end to some place before the end. I can't see the last line in the preview anymore.

Boostnote V 0.12.1 MacOS 10.14.6

fah commented 5 years ago

I switched the options for edit and preview windows "on", to go beyond end of document and now it looks much better.

Flexo013 commented 5 years ago

Thanks for the info! Good to hear that the 'scroll past end' option at least helps a bit.