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

Use custom divider #131

Closed
squidiw opened this issue Dec 18, 2023 · 3 comments
Closed

Use custom divider #131

squidiw opened this issue Dec 18, 2023 · 3 comments

Comments

@squidiw
Copy link

squidiw commented Dec 18, 2023

Hi, wanted to know if there’s a way I can use a custom divider ? For example an svg?

Currently the options are to modify the existing divider but not change it entirely like how the handle can be changed by using slot=handle

@sneas
Copy link
Owner

sneas commented Dec 18, 2023

There is no option to use a custom divider at the moment. What kind of divider would you like to use?

@squidiw
Copy link
Author

squidiw commented Dec 18, 2023

Something like this from a generator - https://kovart.github.io/dashed-border-generator/
Screenshot 2023-12-18 at 8 55 41 AM

And this is a png of it
Line_130

@squidiw
Copy link
Author

squidiw commented Dec 19, 2023

In the future if anyone wants to change the divider, what I ended up doing is,

const slider =  document.querySelector('img-comparison-slider');
  if(slider){
    setTimeout(() => {
      let sliderDivider = slider.shadowRoot;
      let styleSheet = document.createElement('style');
      sliderDivider.insertBefore(styleSheet, sliderDivider.children[0]);

      let rules = [
        `.divider{border:none;width:2px!important;}`,
        `.divider:after{border:none!important;width:2px;background-repeat:repeat-y;background-image:url("data:image/png;base64,........");}`
      ]
      
      rules.forEach((rule, index) => {
           styleSheet.sheet.insertRule(rule, index);
      })
    }, 1000);
  }

@squidiw squidiw closed this as completed Dec 19, 2023
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

No branches or pull requests

2 participants