-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recursively check document height before scrollTo #217
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
400a42f
Recursively check document height before scrollTo
snewcomer 19daa54
default case
snewcomer 63c3a89
further improve tests
snewcomer 6029053
fix tests with mock date util
snewcomer 8592b66
need run
snewcomer 563f041
put back rules
snewcomer 35c9aeb
updatemsg
snewcomer c6d1a03
update lastTry before updating scroll position
snewcomer 3a8b4d9
Use rAF instead of setTimeout for better read/write
snewcomer e3fcd90
Lets try with rAF with afterPaint config as well
snewcomer 8c7af08
add more notes
snewcomer 867a8d5
add another readme note
snewcomer 43448be
grammar
snewcomer 511dde6
remove mock-date
snewcomer f51dbcc
nit
snewcomer 394c811
update comments
snewcomer 06af4f0
add moar comments
snewcomer 4fffc4a
go back to tests the way they were before
snewcomer c0b0c77
add doc block
snewcomer 7aa6f0a
spellings
snewcomer 3772500
change config names
snewcomer 8119f12
cancel animationFrame is need be
snewcomer 19442a2
update based on feedback
snewcomer 5f152a3
use default false
snewcomer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,21 @@ const RouterScroll = Service.extend({ | |
key: null, | ||
scrollElement: 'window', | ||
targetElement: null, | ||
delayScrollTop: false, | ||
isFirstLoad: true, | ||
preserveScrollPosition: false, | ||
delayScrollTop: false, | ||
// ember-app-scheduler properties | ||
scrollWhenPainted: false, | ||
scrollWhenIdle: false, | ||
|
||
init(...args) { | ||
this._super(...args); | ||
this._loadConfig(); | ||
set(this, 'scrollMap', { default: { x: 0, y: 0 }}); | ||
set(this, 'scrollMap', { | ||
default: { | ||
x: 0, y: 0 | ||
} | ||
}); | ||
}, | ||
|
||
unsetFirstLoad() { | ||
|
@@ -47,7 +54,10 @@ const RouterScroll = Service.extend({ | |
|
||
// if we are looking to where to transition to next, we need to set the default to the position | ||
// of the targetElement on screen | ||
set(scrollMap, 'default', { x, y }); | ||
set(scrollMap, 'default', { | ||
x, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent formatting between this and line 26. |
||
y | ||
}); | ||
} | ||
} else if ('window' === scrollElement) { | ||
x = window.scrollX; | ||
|
@@ -63,7 +73,10 @@ const RouterScroll = Service.extend({ | |
|
||
// only a `key` present after first load | ||
if (key && 'number' === typeOf(x) && 'number' === typeOf(y)) { | ||
set(scrollMap, key, { x, y }); | ||
set(scrollMap, key, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, too. |
||
x, | ||
y | ||
}); | ||
} | ||
}, | ||
|
||
|
@@ -84,10 +97,14 @@ const RouterScroll = Service.extend({ | |
set(this, 'targetElement', targetElement); | ||
} | ||
|
||
const delayScrollTop = config.routerScroll.delayScrollTop; | ||
if (delayScrollTop === true) { | ||
set(this, 'delayScrollTop', true); | ||
} | ||
const { | ||
scrollWhenPainted = false, | ||
scrollWhenIdle = false, | ||
delayScrollTop = false | ||
} = config.routerScroll; | ||
set(this, 'delayScrollTop', delayScrollTop); | ||
set(this, 'scrollWhenPainted', scrollWhenPainted); | ||
set(this, 'scrollWhenIdle', scrollWhenIdle); | ||
} | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// https://stackoverflow.com/questions/13382516/getting-scroll-bar-width-using-javascript | ||
export function getScrollBarWidth() { | ||
let outer = document.createElement('div'); | ||
outer.style.visibility = 'hidden'; | ||
outer.style.width = '100px'; | ||
outer.style.msOverflowStyle = 'scrollbar'; | ||
|
||
document.body.appendChild(outer); | ||
|
||
let widthNoScroll = outer.offsetWidth; | ||
// force scrollbars | ||
outer.style.overflow = 'scroll'; | ||
|
||
// add innerdiv | ||
let inner = document.createElement('div'); | ||
inner.style.width = '100%'; | ||
outer.appendChild(inner); | ||
|
||
let widthWithScroll = inner.offsetWidth; | ||
|
||
// remove divs | ||
outer.parentNode.removeChild(outer); | ||
|
||
return widthNoScroll - widthWithScroll; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also want to do this if the page is optimistically rendered.