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

Setting transistionDuration property does not work #2

Open
fidian opened this issue Feb 16, 2024 · 6 comments
Open

Setting transistionDuration property does not work #2

fidian opened this issue Feb 16, 2024 · 6 comments

Comments

@fidian
Copy link

fidian commented Feb 16, 2024

I tried this and it did not work.

const carousel = document.createElement("wc-carousel-lite");
carousel.transistionDuration = 1000;
carousel.interval = 6000;

The carousel appears when I add it to the DOM but there's no transition. It was weird because I had a hardcoded example working fine in HTML, so I tried an attribute.

const carousel = document.createElement("wc-carousel-lite");
carousel.setAttribute("transition-duration", "1000");
carousel.interval = 6000;

This showed the carousel but the transition duration appeared to be the same length as the interval; both appeared to be set to 1000ms. So I tried setting the interval through an attribute.

const carousel = document.createElement("wc-carousel-lite");
carousel.setAttribute("transition-duration", "1000");
carousel.setAttribute("interval", 6000);

This worked.

Either the documentation is wrong and transitionDuration can't be set or this is a minor bug in the component.

@jutunen
Copy link
Member

jutunen commented Feb 16, 2024

Notice the typo in your code:

transistion vs. transition

@fidian
Copy link
Author

fidian commented Feb 16, 2024

Yes, I had a typo while composing the issue report but I assure you it was triple checked in my code. I didn't copy and paste the example code into the bug report.

Here's a CodePen to illustrate the problem. Note that because I couldn't find an easy CDN for the script, I just copied and pasted it into the JavaScript side. Not ideal, but a quick way to show that the bug exists.

https://codepen.io/fidian/pen/wvONEYM

@jutunen
Copy link
Member

jutunen commented Feb 16, 2024

Yes, you're right, the CodePen you provided does not work.

However, this code snippet works:

<!DOCTYPE html>
<html>
   <head>
      <script defer src='wc-carousel-lite.min.js'></script>
   </head>
   <script>
      function start() {
      const carousel = document.createElement("wc-carousel-lite");
      carousel.innerHTML = `
         <img src="https://placekitten.com/g/400/200" class="item" width="400">
         <img src="https://placekitten.com/g/300/200" class="item" width="300">
         <img src="https://placekitten.com/g/250/200" class="item" width="250"> 
      `
      carousel.transitionDuration = 3000;
      carousel.interval = 6000;
      carousel.infinite = true;
      carousel.autoplay = true;
      
      document.getElementById('target').appendChild(carousel);
      }
      
   </script>
   <body onload="start();">
      <div id="target"></div>
   </body>
</html>

Unfortunately, I have no idea why your CodePen doesn't work but that code snippet works.

@fidian
Copy link
Author

fidian commented Feb 16, 2024

Where is your copy of wc-carousel-lite.min.js hosted? I copied the one off the demo site because I couldn't link to an http URL from a secure https location. I tried looking for a UMD version but it also does not work because it's trying to use export.

Demo site: http://135.181.40.67/wc-carousel-lite/
My attempt at using the UMD version directly: https://codepen.io/fidian/pen/poYGxMQ

@jutunen
Copy link
Member

jutunen commented Feb 16, 2024

Here it is: http://135.181.40.67/wc-carousel-lite/wc-carousel-lite.min.js

For the code snippet I just wrote, I just keep wc-carousel-lite.min.js and the snippet in the same directory and then open the snippet file with browser.

@fidian
Copy link
Author

fidian commented Feb 17, 2024

So, what is the issue with the first version on CodePen? I checked again and it appears that I am doing everything correctly but I still may have mistyped something. Did you copy and paste my JavaScript and give it a shot? What's the path forward for this issue?

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