Skip to content
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

Update all the things #142

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Various tweaks
  • Loading branch information
RobbieTheWagner committed Jul 13, 2022
commit 6ba2f74322bc2dc805e828537fc5c2ee856ebd9f
24 changes: 13 additions & 11 deletions addon/components/ember-scrollable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const scrollbarSelector = '.tse-scrollbar';
const contentSelector = '.tse-content';

export default Component.extend(DomMixin, {
scrollbarThickness: service(),

layout,
tagName: '',

Expand Down Expand Up @@ -124,10 +126,9 @@ export default Component.extend(DomMixin, {
*/
verticalScrollbar: null,

scrollbarThickness: service(),

didReceiveAttrs() {
this._super();
this._super(...arguments);

const horizontal = this.horizontal;
const vertical = this.horizontal;
// Keep backwards compatible functionality wherein vertical is default when neither vertical or horizontal are explicitly set
Expand All @@ -148,8 +149,17 @@ export default Component.extend(DomMixin, {
this.el.addEventListener('mousemove', this.mouseMoveHandler);
}),

/**
* Update action should be called when size of the scroll area changes
*/
recalculate: action(function () {
// TODO this is effectively the same as `update`, except for update returns the passed in value. Keep one, and rename `resizeScrollbar` to be clear.
this.resizeScrollbar();
}),

willDestroy() {
this._super(...arguments);

this.el?.removeEventListener(
'transitionend webkitTransitionEnd',
this._resizeHandler
Expand Down Expand Up @@ -471,14 +481,6 @@ export default Component.extend(DomMixin, {
},

actions: {
/**
* Update action should be called when size of the scroll area changes
*/
recalculate() {
// TODO this is effectively the same as `update`, except for update returns the passed in value. Keep one, and rename `resizeScrollbar` to be clear.
this.resizeScrollbar();
},

/**
* Can be called when scrollbars change as a result of value change,
*
Expand Down
2 changes: 0 additions & 2 deletions addon/components/ember-scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export default Component.extend(DomMixin, {
onDragEnd() {},

horizontal: false,
isDragging: false,
showHandle: false,
handleSize: null,
handleOffset: 0,

Expand Down
8 changes: 4 additions & 4 deletions addon/templates/components/ember-scrollable.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
if vertical 'vertical'
}}'
{{did-insert this.elementInserted}}
{{on-resize (action 'recalculate')}}
{{on-resize this.recalculate}}
>
{{#if horizontal}}
{{ember-scrollbar
handleOffset=horizontalHandleOffset
handleSize=horizontalHandleSize
horizontal=true
showHandle=showHandle
showHandle=this.showHandle
isDragging=isHorizontalDragging
onJumpTo=(action 'horizontalJumpTo')
onDrag=(action 'horizontalDrag')
Expand All @@ -23,7 +23,7 @@
handleOffset=verticalHandleOffset
handleSize=verticalHandleSize
horizontal=false
showHandle=showHandle
showHandle=this.showHandle
isDragging=isVerticalDragging
onJumpTo=(action 'verticalJumpTo')
onDrag=(action 'verticalDrag')
Expand All @@ -35,7 +35,7 @@
<div class='tse-content scrollable-content'>
{{yield
(hash
recalculate=(action 'recalculate')
recalculate=this.recalculate
update=(action 'update')
scrollTop=(action 'scrollTop')
)
Expand Down
6 changes: 5 additions & 1 deletion addon/templates/components/ember-scrollbar.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<div class="drag-handle {{if showHandle 'visible'}}" onmousedown={{action 'startDrag'}} style={{handleStyles}}></div>
<div
class='drag-handle {{if @showHandle 'visible'}}'
style={{this.handleStyles}}
{{on 'mousedown' (action 'startDrag')}}
></div>