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

Add PauseOnHover for autoplay feature #5

Merged
merged 2 commits into from
Oct 19, 2022
Merged

Add PauseOnHover for autoplay feature #5

merged 2 commits into from
Oct 19, 2022

Conversation

vuquangpham
Copy link
Contributor

Pause On Hover

I have added a little bit of code for the autoplay feature.

With that code, we can control the autoplay feature by hovering over it. You can turn on this option by passing an option pauseOnHover through HTML attribute or Javascript object. And when the option pauseOnHover is false, I also removed the event listener for optimizing performance.

@netlify
Copy link

netlify bot commented Oct 18, 2022

Deploy Preview for overlapping-slider ready!

Name Link
🔨 Latest commit 88c5f61
🔍 Latest deploy log https://app.netlify.com/sites/overlapping-slider/deploys/634e8a3ac482ac0009681945
😎 Deploy Preview https://deploy-preview-5--overlapping-slider.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@vuquangpham vuquangpham self-assigned this Oct 18, 2022
@vuquangpham vuquangpham added the enhancement New feature or request label Oct 18, 2022
@vuquangpham vuquangpham linked an issue Oct 18, 2022 that may be closed by this pull request
3 tasks
@phucbm phucbm self-requested a review October 18, 2022 09:53
Copy link
Member

@phucbm phucbm left a comment

Choose a reason for hiding this comment

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

Please check my comments.

README.md Outdated
| Attribute | As for option | Description |
|-------------------------------|--------------------------------------|-------------------------------------------------|
| `data-os-autoplay="2` | `autoplay: 2` | Add autoplay option through html attribute |
| `data-os-pauseOnHover="true"` | `pauseOnHover: true"` | Enable pauseOnHover feature (only for autoplay) |
Copy link
Member

Choose a reason for hiding this comment

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

src/_index.js Outdated
// pauseOnHover (priority: attribute > options)
if(this.wrapper.hasAttribute(this._attr.pauseOnHover)){
const isPauseOnHover = this.wrapper.getAttribute(this._attr.pauseOnHover).toLowerCase().trim();
this.options.pauseOnHover = isPauseOnHover === "true";
Copy link
Member

Choose a reason for hiding this comment

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

Whenever the attribute for pauseOnHover appear in the wrapper element, we will have pauseOnHover: true.

Don't care what the value is.

This is just the same with the swipe option which you might have had a look already, haven't you?

@@ -84,6 +84,8 @@ <h2>#3 Autoplay</h2>
<button data-select="play" data-id="slider-3" class="btn green disabled">Play</button>
<button data-select="prev" data-id="slider-3" class="btn">Previous</button>
<button data-select="next" data-id="slider-3" class="btn">Next</button>
<button data-select="remove-poh" data-id="slider-3" class="btn">Remove PauseOnHover</button>
<button data-select="register-poh" data-id="slider-3" class="btn">Add PauseOnHover</button>
Copy link
Member

Choose a reason for hiding this comment

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

There should be only one clickable button at a time. You can either use .disabled class (see Pause and Play button) or display none/block as we also don't have so much spacing here to have so many buttons.

@vuquangpham
Copy link
Contributor Author

I have fixed it. Please check again!

@phucbm phucbm merged commit aaaff02 into main Oct 19, 2022
@phucbm phucbm deleted the PauseOnHover branch October 19, 2022 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add option pauseOnHover
2 participants