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

[Feature] Hash cloak option on AnchorScrollTo (WIP) #186

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

antoine4livre
Copy link
Contributor

@antoine4livre antoine4livre commented Mar 21, 2024

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Add the update of the hash in the url after animation complete and add an option to disable it.

πŸ“ Checklist

Feature todos

PR todos

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.
  • I have updated the changelog.

@antoine4livre antoine4livre self-assigned this Mar 21, 2024
Copy link

github-actions bot commented Mar 21, 2024

Export Size

@studiometa/ui

Name Size Diff
AnchorScrollTo 308 B +65 B (+26.75%) πŸ”Ί
TableOfContentAnchor 603 B +53 B (+9.64%) πŸ”Ί
TableOfContent 782 B +40 B (+5.39%) πŸ”Ί
ATOMS 3.8 kB +36 B (+0.96%) πŸ”Ί
MOLECULES 6.99 kB +44 B (+0.63%) πŸ”Ί
ALL 11.22 kB +33 B (+0.30%) πŸ”Ί
Unchanged

@studiometa/ui

Name Size Diff
AbstractPrefetch 411 B -
AbstractScrollAnimation 461 B -
AbstractSliderChild 2.46 kB -
Accordion 1.06 kB -
AccordionItem 1.02 kB -
Action 508 B -
animationScrollWithEase 272 B -
CircularMarquee 339 B -
Cursor 665 B -
Draggable 327 B -
Figure 694 B -
FigureTwicpics 1.15 kB -
Frame 1.62 kB -
FrameAnchor 201 B -
FrameForm 198 B -
FrameTarget 777 B -
LargeText 492 B -
LazyInclude 418 B -
loadImage 694 B -
Menu 1.38 kB -
MenuBtn 230 B -
MenuList 943 B -
Modal 908 B -
ModalWithTransition 1.02 kB -
ORGANISMS 1.68 kB -
Panel 1.26 kB -
PrefetchWhenOver 468 B -
PrefetchWhenVisible 480 B -
PRIMITIVES 632 B -
ScrollAnimation 513 B -
ScrollAnimationChild 650 B -
ScrollAnimationChildWithEase 851 B -
ScrollAnimationParent 712 B -
ScrollAnimationWithEase 711 B -
ScrollReveal 622 B -
Sentinel 217 B -
Slider 2.26 kB -
SliderBtn 2.62 kB -
SliderCount 2.49 kB -
SliderDots 2.7 kB -
SliderDrag 353 B -
SliderItem 733 B -
SliderProgress 2.54 kB -
Sticky 859 B -
Tabs 625 B -
Transition 387 B -

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 28.19%. Comparing base (7e6c2f0) to head (f99e5e1).

Files Patch % Lines
packages/ui/atoms/AnchorScrollTo/AnchorScrollTo.ts 0.00% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #186      +/-   ##
===========================================
- Coverage    28.33%   28.19%   -0.14%     
===========================================
  Files           49       49              
  Lines         1246     1252       +6     
  Branches       239      231       -8     
===========================================
  Hits           353      353              
+ Misses         893      830      -63     
- Partials         0       69      +69     
Flag Coverage Ξ”
unittests 28.19% <0.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

return;
}

window.location.hash = this.targetSelector;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we avoid the problem with a specified offset ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

historyReplace({ hash: 'hello-world' });

@titouanmathis titouanmathis marked this pull request as draft March 22, 2024 13:19
@antoine4livre antoine4livre force-pushed the feature/AnchorScrollto-hash-cloak branch from 127357f to f99e5e1 Compare March 27, 2024 16:07
return;
}

window.location.hash = this.targetSelector;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

historyReplace({ hash: 'hello-world' });

@@ -27,10 +30,21 @@ export class AnchorScrollTo<T extends BaseProps = BaseProps> extends Base<Anchor
* @param {MouseEvent} event
* @returns {void}
*/
onClick(event) {
async onClick(event) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
async onClick(event) {
async onClick(event) {
if (
this.$el.pathname !== window.location.pathname ||
this.$el.origin !== window.location.origin
) {
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant