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

Showcase .gts - Shw::Autoscrollable #2426

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { scheduleOnce } from '@ember/runloop';
import { AutoscrollableDirectionValues } from './types';
import type { AutoscrollableDirections } from './types';

function centerScrollableArea({
const centerScrollableArea = ({
element,
direction,
horizontalShift,
Expand All @@ -20,7 +20,7 @@ function centerScrollableArea({
direction: AutoscrollableDirections;
horizontalShift: number;
verticalShift: number;
}) {
}) => {
if (
direction === AutoscrollableDirectionValues.Both ||
direction === AutoscrollableDirectionValues.X
Expand All @@ -35,7 +35,7 @@ function centerScrollableArea({
element.scrollTop =
verticalShift + (element.scrollHeight - element.offsetHeight) / 2;
}
}
};

interface ShwAutoscrollableSignature {
Args: {
Expand All @@ -58,4 +58,14 @@ export default class ShwAutoscrollable extends Component<ShwAutoscrollableSignat
verticalShift: this.args.verticalShift ?? 0,
});
});

<template>
<div
class="shw-autoscrollable__container"
...attributes
{{this.autoscroll}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I tried to move the autoscroll modifier definition outside of the class/Component declaration, but it didn't work: for some reasons that I don't understand only the last instance actually called the centerScrollableArea function.

If you know why and want to give it a go and try do it "properly" feel free to push directly in the branch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did attempt to do the same but gave up as this modifier is closely tide to this components. It might be good to follow up as a stand alone PR in the future

>
{{yield}}
</div>
</template>
}
8 changes: 0 additions & 8 deletions showcase/app/components/shw/autoscrollable/index.hbs

This file was deleted.

2 changes: 1 addition & 1 deletion showcase/types/template-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import ShwAutoscrollable from '../app/components/shw/autoscrollable';
import ShwAutoscrollable from '../app/components/shw/autoscrollable/index';
import ShwDivider from '../app/components/shw/divider';
import ShwFlex from '../app/components/shw/flex';
import ShwFlexItem from '../app/components/shw/flex/item';
Expand Down