luncheon / ripplet.js

Fully controllable vanilla-js material design ripple effect generator.
https://luncheon.github.io/ripplet.js/demo/
Do What The F*ck You Want To Public License
78 stars 7 forks source link

RTL support #2

Closed 726b closed 4 years ago

726b commented 4 years ago

When using ripplet in RTL container, the ripple X position is off. This can be fixed with adding a 'direction' option:

export const defaultOptions = {
  ...
  direction: 'ltr' as string | null, // ltr as default
}

and then changing line 117 to:

/^rtl$/i.test(options.direction!) ? rippletStyle.marginRight = `${targetRect.right - clientX - radius}px` : rippletStyle.marginLeft = `${clientX - targetRect.left - radius}px`
luncheon commented 4 years ago

Thank you for reporting.

I have confirmed that the problem reproduces. https://codepen.io/luncheon/pen/MWKrYxa

I prefer to fix it without adding any options if possible. I think the following is sufficient to check if a container is RTL.

If you have any thoughts, please comment.

726b commented 4 years ago

That's even better!

By the way, forgot to say, ripplet is a very nice package ― thank you for a great job.

luncheon commented 4 years ago

v0.2.1 that fixes this issue has been released! If it hasn't been fixed in your case, please reopen this issue.