-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move scrollbar thickness measurement to service
- Loading branch information
1 parent
8e68179
commit 3572c3d
Showing
3 changed files
with
31 additions
and
30 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Ember from 'ember'; | ||
|
||
const { | ||
computed, | ||
Service | ||
} = Ember; | ||
|
||
export default Service.extend({ | ||
thickness: computed(() => { | ||
const tempEl = $(` | ||
<div class="scrollbar-width-tester" style="width: 50px; position: absolute; left: -100px;"> | ||
<div style="overflow: scroll;"> | ||
<div class="scrollbar-width-tester__inner"></div> | ||
</div> | ||
</div> | ||
`); | ||
$('body').append(tempEl); | ||
const width = $(tempEl).width(); | ||
const widthMinusScrollbars = $('.scrollbar-width-tester__inner', tempEl).width(); | ||
tempEl.remove(); | ||
|
||
return (width - widthMinusScrollbars); | ||
}) | ||
}); |
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 @@ | ||
export { default } from 'ember-scrollable/services/scrollbar-thickness'; |