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

Fix bug with element inside anchor #248

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix anchor preventDefault not being able to click link
  • Loading branch information
hdodov committed May 15, 2019
commit 1b84563b0e284ef0772e1ce6933331ad88cd5254
5 changes: 4 additions & 1 deletion src/siema.js
Original file line number Diff line number Diff line change
@@ -93,6 +93,7 @@ export default class Siema {
if (this.config.draggable) {
// Keep track pointer hold and dragging distance
this.pointerDown = false;
this.draggedBeyondThreshold = false;
this.drag = {
startX: 0,
endX: 0,
@@ -511,6 +512,7 @@ export default class Siema {
// mark preventClick prop as a true
// to detemine about browser redirection later on
this.drag.preventClick = this.insideAnchor(e.target);
this.draggedBeyondThreshold = false;
}


@@ -552,6 +554,7 @@ export default class Siema {
this.selector.style.cursor = '-webkit-grabbing';
this.sliderFrame.style.webkitTransition = `all 0ms ${this.config.easing}`;
this.sliderFrame.style.transition = `all 0ms ${this.config.easing}`;
this.draggedBeyondThreshold = Math.abs(this.drag.startX - this.drag.endX) > this.config.threshold;

const currentSlide = this.config.loop ? this.currentSlide + this.perPage : this.currentSlide;
const currentOffset = currentSlide * (this.selectorWidth / this.perPage);
@@ -584,7 +587,7 @@ export default class Siema {
clickHandler(e) {
// if the dragged element is a link
// prevent browsers from folowing the link
if (this.drag.preventClick) {
if (this.drag.preventClick && this.draggedBeyondThreshold) {
e.preventDefault();
}
this.drag.preventClick = false;