Skip to content
Snippets Groups Projects
Commit 57daa0cd authored by Olivia206's avatar Olivia206
Browse files

fix

parent dc0e2a6a
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ class DraggableBlock {
this.items = this.list.querySelectorAll('.draggable-item');
this.previous = this.block.querySelector('.previous');
this.next = this.block.querySelector('.next');
this.isPointerDown = false;
this.clicOnBtn = false;
this.index = 0;
......@@ -58,45 +59,54 @@ class DraggableBlock {
this.clicOnBtn = true;
this.goTo(this.index-1);
});
this.previous.addEventListener('pointerup', () => {
this.isPointerDown = false;
});
this.next.addEventListener('click', () => {
this.clicOnBtn = true;
this.goTo(this.index+1);
});
this.next.addEventListener('pointerup', () => {
this.isPointerDown = false;
});
}
handlePointers () {
let endEvents = ['pointerup'],
startX,
let startX,
endX,
threshold = 30,
isPointerDown = false;
threshold = 30;
this.content.style.touchAction = 'pan-y';
this.block.addEventListener('pointerdown', (event) => {
if (!this.clicOnBtn) {
if (event.target !== this.next && event.target !== this.previous) {
this.clicOnBtn = false;
this.isPointerDown = true;
this.content.classList.add('is-grabbing');
isPointerDown = true;
console.log(isPointerDown)
}
startX = event.clientX;
startX = event.clientX;
}
});
this.block.addEventListener('pointermove', (event) => {
this.isManipulated = isPointerDown;
endX = event.clientX;
if (this.isManipulated) {
if (this.isPointerDown) {
event.preventDefault();
this.items.forEach((item) => {
item.style.pointerEvents = "none";
});
}
});
endEvents.forEach(event => {
this.block.addEventListener(event, (event) => {
isPointerDown = false;
this.block.addEventListener('pointerup', (event) => {
if (this.isPointerDown) {
this.isPointerDown = false;
this.content.classList.remove('is-grabbing');
const endX = event.clientX;
this.onManipulationEnd(startX, endX, threshold);
});
}
});
}
......@@ -123,7 +133,7 @@ class DraggableBlock {
} else if (start < end - threshold) {
this.goTo(this.index-1);
}
this.clicOnBtn = true;
this.content.classList.remove('is-grabbing');
this.items.forEach((item) => {
item.style.pointerEvents = "all";
......
......@@ -108,7 +108,7 @@
@include media-breakpoint-down(desktop)
.timeline-events
position: relative
.timeline-arrows
.actions-arrows
left: 0
position: absolute
top: calc(#{$spacing-4/2} + var(--min-title-height))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment