Sfoglia il codice sorgente

Improve the drag precision.

NaotoshiFujita 3 anni fa
parent
commit
15898b5920

+ 1 - 1
dist/js/splide-renderer.min.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.2.2
+ * Version  : 3.2.3
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */

+ 4 - 4
dist/js/splide.cjs.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.2.2
+ * Version  : 3.2.3
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -1789,21 +1789,21 @@ function Drag(Splide2, Components2, options) {
     }
     lastEvent = e;
     if (e.cancelable) {
+      const diff = coordOf(e) - coordOf(baseEvent);
       if (dragging) {
+        Move.translate(basePosition + constrain(diff));
         const expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
         const exceeded = hasExceeded !== (hasExceeded = exceededLimit());
         if (expired || exceeded) {
           save(e);
         }
-        Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
         emit(EVENT_DRAGGING);
         clickPrevented = true;
         prevent(e);
       } else {
-        const diff = abs(coordOf(e) - coordOf(baseEvent));
         let { dragMinThreshold: thresholds } = options;
         thresholds = isObject(thresholds) ? thresholds : { mouse: 0, touch: +thresholds || 10 };
-        dragging = diff > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
+        dragging = abs(diff) > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
         if (isSliderDirection()) {
           prevent(e);
         }

+ 4 - 4
dist/js/splide.esm.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.2.2
+ * Version  : 3.2.3
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -1785,21 +1785,21 @@ function Drag(Splide2, Components2, options) {
     }
     lastEvent = e;
     if (e.cancelable) {
+      const diff = coordOf(e) - coordOf(baseEvent);
       if (dragging) {
+        Move.translate(basePosition + constrain(diff));
         const expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
         const exceeded = hasExceeded !== (hasExceeded = exceededLimit());
         if (expired || exceeded) {
           save(e);
         }
-        Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
         emit(EVENT_DRAGGING);
         clickPrevented = true;
         prevent(e);
       } else {
-        const diff = abs(coordOf(e) - coordOf(baseEvent));
         let { dragMinThreshold: thresholds } = options;
         thresholds = isObject(thresholds) ? thresholds : { mouse: 0, touch: +thresholds || 10 };
-        dragging = diff > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
+        dragging = abs(diff) > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
         if (isSliderDirection()) {
           prevent(e);
         }

+ 5 - 4
dist/js/splide.js

@@ -4,7 +4,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
 /*!
  * Splide.js
- * Version  : 3.2.2
+ * Version  : 3.2.3
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -2153,7 +2153,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       lastEvent = e;
 
       if (e.cancelable) {
+        var diff = coordOf(e) - coordOf(baseEvent);
+
         if (dragging) {
+          Move.translate(basePosition + constrain(diff));
           var expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
           var exceeded = hasExceeded !== (hasExceeded = exceededLimit());
 
@@ -2161,18 +2164,16 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
             save(e);
           }
 
-          Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
           emit(EVENT_DRAGGING);
           clickPrevented = true;
           prevent(e);
         } else {
-          var diff = abs(coordOf(e) - coordOf(baseEvent));
           var thresholds = options.dragMinThreshold;
           thresholds = isObject(thresholds) ? thresholds : {
             mouse: 0,
             touch: +thresholds || 10
           };
-          dragging = diff > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
+          dragging = abs(diff) > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
 
           if (isSliderDirection()) {
             prevent(e);

File diff suppressed because it is too large
+ 0 - 0
dist/js/splide.js.map


File diff suppressed because it is too large
+ 1 - 1
dist/js/splide.min.js


BIN
dist/js/splide.min.js.gz


+ 1 - 1
dist/types/components/Drag/Drag.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"Drag.d.ts","sourceRoot":"","sources":["Drag.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKjE;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,OAAO,CAAE,QAAQ,EAAE,OAAO,GAAI,IAAI,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,aAAa,CAoU9F"}
+{"version":3,"file":"Drag.d.ts","sourceRoot":"","sources":["Drag.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKjE;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,OAAO,CAAE,QAAQ,EAAE,OAAO,GAAI,IAAI,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,aAAa,CAsU9F"}

+ 1 - 1
package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "3.2.1",
+  "version": "3.2.3",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "3.2.2",
+  "version": "3.2.3",
   "description": "Splide is a lightweight, flexible and accessible slider/carousel. No dependencies, no Lighthouse errors.",
   "author": "Naotoshi Fujita",
   "license": "MIT",

+ 5 - 3
src/js/components/Drag/Drag.ts

@@ -154,7 +154,11 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
     lastEvent = e;
 
     if ( e.cancelable ) {
+      const diff = coordOf( e ) - coordOf( baseEvent );
+
       if ( dragging ) {
+        Move.translate( basePosition + constrain( diff ) );
+
         const expired  = timeOf( e ) - timeOf( baseEvent ) > LOG_INTERVAL;
         const exceeded = hasExceeded !== ( hasExceeded = exceededLimit() );
 
@@ -162,15 +166,13 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
           save( e );
         }
 
-        Move.translate( basePosition + constrain( coordOf( e ) - coordOf( baseEvent ) ) );
         emit( EVENT_DRAGGING );
         clickPrevented = true;
         prevent( e );
       } else {
-        const diff = abs( coordOf( e ) - coordOf( baseEvent ) );
         let { dragMinThreshold: thresholds } = options;
         thresholds = isObject( thresholds ) ? thresholds : { mouse: 0, touch: +thresholds || 10 };
-        dragging   = diff > ( isTouchEvent( e ) ? thresholds.touch : thresholds.mouse );
+        dragging   = abs( diff ) > ( isTouchEvent( e ) ? thresholds.touch : thresholds.mouse );
 
         if ( isSliderDirection() ) {
           prevent( e );

Some files were not shown because too many files changed in this diff