supercharged-slider
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -184,3 +184,2 @@ var index = ""; | ||
let isDragging = false; | ||
let lastPositionBeforeMove = 0; | ||
let lastCursorPosition = 0; | ||
@@ -200,3 +199,3 @@ let lastWrapperPosition = 0; | ||
lastCursorPosition = mousePosition; | ||
lastWrapperPosition = Math.min(newPosition, threshold); | ||
lastWrapperPosition = Math.max(Math.min(newPosition, threshold), 0); | ||
slider.scrollWrapperTo(lastWrapperPosition); | ||
@@ -209,3 +208,2 @@ }; | ||
isDragging = true; | ||
lastPositionBeforeMove = slider.wrapperPosition; | ||
slider.wrapper.style.transitionDuration = "0ms"; | ||
@@ -218,14 +216,5 @@ document.addEventListener("mousemove", onMouseMove); | ||
const rectKey = isVertical() ? "slideHeight" : "slideWidth"; | ||
const threshold = (slider[rectKey] || 0) / 4; | ||
const difference = lastPositionBeforeMove - lastWrapperPosition; | ||
const movedRight = difference < 0; | ||
const passedThreshold = Math.abs(difference) > threshold; | ||
if (passedThreshold) { | ||
if (movedRight) | ||
slider.next(); | ||
else | ||
slider.prev(); | ||
} else { | ||
slider.scrollWrapperTo(lastPositionBeforeMove); | ||
} | ||
console.log(lastWrapperPosition); | ||
const newIndex = Math.round(lastWrapperPosition / (slider[rectKey] || 0)); | ||
slider.slideTo(newIndex); | ||
lastCursorPosition = 0; | ||
@@ -232,0 +221,0 @@ isDragging = false; |
{ | ||
"name": "supercharged-slider", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "A super modular tiny slider library.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -11,3 +11,2 @@ import { Middleware } from '~/types'; | ||
let lastPositionBeforeMove = 0; | ||
let lastCursorPosition = 0; | ||
@@ -31,3 +30,3 @@ let lastWrapperPosition = 0; | ||
lastCursorPosition = mousePosition; | ||
lastWrapperPosition = Math.min(newPosition, threshold); | ||
lastWrapperPosition = Math.max(Math.min(newPosition, threshold), 0); | ||
@@ -42,3 +41,2 @@ slider.scrollWrapperTo(lastWrapperPosition); | ||
isDragging = true; | ||
lastPositionBeforeMove = slider.wrapperPosition; | ||
@@ -53,13 +51,6 @@ slider.wrapper.style.transitionDuration = '0ms'; | ||
const threshold = (slider[rectKey] || 0) / 4; | ||
const difference = lastPositionBeforeMove - lastWrapperPosition; | ||
const movedRight = difference < 0; | ||
const passedThreshold = Math.abs(difference) > threshold; | ||
console.log(lastWrapperPosition); | ||
const newIndex = Math.round(lastWrapperPosition / (slider[rectKey] || 0)); | ||
if (passedThreshold) { | ||
if (movedRight) slider.next(); | ||
else slider.prev(); | ||
} else { | ||
slider.scrollWrapperTo(lastPositionBeforeMove); | ||
} | ||
slider.slideTo(newIndex); | ||
@@ -66,0 +57,0 @@ lastCursorPosition = 0; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
35046
862