mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Rename variables
This commit is contained in:
@@ -39,25 +39,28 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
targetHeight = _.get(codeDoc, 'height')
|
targetHeight = _.get(codeDoc, 'height')
|
||||||
}
|
}
|
||||||
|
|
||||||
const factor = srcTop / srcHeight
|
const distance = (targetHeight * srcTop / srcHeight) - targetTop
|
||||||
const previewTarget = targetHeight * factor
|
const framerate = 1000 / 60
|
||||||
const distance = previewTarget - targetTop
|
const frames = 20
|
||||||
|
const refractory = frames * framerate
|
||||||
|
|
||||||
this.userScroll = false
|
this.userScroll = false
|
||||||
const s = 20
|
|
||||||
let i = s
|
let frame = 0
|
||||||
let f, t
|
let scrollPos, time
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
t = (s - i) / s
|
time = frame / frames
|
||||||
f = t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t
|
scrollPos = time < 0.5
|
||||||
if (e.doc) _.set(previewDoc, 'body.scrollTop', targetTop + f * distance)
|
? 2 * time * time // ease in
|
||||||
else _.get(this, 'refs.code.editor').scrollTo(0, targetTop + f * distance)
|
: -1 + (4 - 2 * time) * time // ease out
|
||||||
if (!i) {
|
if (e.doc) _.set(previewDoc, 'body.scrollTop', targetTop + scrollPos * distance)
|
||||||
|
else _.get(this, 'refs.code.editor').scrollTo(0, targetTop + scrollPos * distance)
|
||||||
|
if (frame >= frames) {
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
setTimeout(() => { this.userScroll = true }, 400)
|
setTimeout(() => { this.userScroll = true }, refractory)
|
||||||
}
|
}
|
||||||
i -= 1
|
frame++
|
||||||
}, 1000 / 60)
|
}, framerate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user