Explorar o código

allow to execute autopan even if edge of component is touching edge of a screen.

Ievgen Naida %!s(int64=5) %!d(string=hai) anos
pai
achega
569d216aa5
Modificáronse 5 ficheiros con 28 adicións e 18 borrados
  1. 13 9
      lib/animation-timeline.js
  2. 0 0
      lib/animation-timeline.min.js
  3. 1 1
      package.json
  4. 4 0
      src/settings/timelineConsts.ts
  5. 10 8
      src/timeline.ts

+ 13 - 9
lib/animation-timeline.js

@@ -547,6 +547,8 @@ var TimelineConsts = function TimelineConsts() {
   timelineConsts_defineProperty(this, "doubleClickTimeoutMs", 400);
   timelineConsts_defineProperty(this, "doubleClickTimeoutMs", 400);
 
 
   timelineConsts_defineProperty(this, "scrollFinishedTimeoutMs", 500);
   timelineConsts_defineProperty(this, "scrollFinishedTimeoutMs", 500);
+
+  timelineConsts_defineProperty(this, "autoPanByScrollPadding", 10);
 };
 };
 // CONCATENATED MODULE: ./src/enums/timelineCursorType.ts
 // CONCATENATED MODULE: ./src/enums/timelineCursorType.ts
 var TimelineCursorType;
 var TimelineCursorType;
@@ -1724,11 +1726,13 @@ var timeline_Timeline = /*#__PURE__*/function (_TimelineEventsEmitte) {
       var y = pos.y;
       var y = pos.y;
       var isChanged = false;
       var isChanged = false;
       var speedX = 0;
       var speedX = 0;
-      var speedY = 0;
-      var isLeft = x <= 0;
-      var isRight = x >= this.canvas.clientWidth;
-      var isTop = y <= 0;
-      var isBottom = y >= this.canvas.clientHeight;
+      var speedY = 0; // Small offset to start auto pan earlier.
+
+      var bounds = this.consts.autoPanByScrollPadding;
+      var isLeft = x <= bounds;
+      var isRight = x >= this.canvas.clientWidth - bounds;
+      var isTop = y <= bounds;
+      var isBottom = y >= this.canvas.clientHeight - bounds;
       var newWidth = null;
       var newWidth = null;
       var newHeight = null;
       var newHeight = null;
 
 
@@ -1744,19 +1748,19 @@ var timeline_Timeline = /*#__PURE__*/function (_TimelineEventsEmitte) {
 
 
         if (isLeft) {
         if (isLeft) {
           // Get normalized speed.
           // Get normalized speed.
-          speedX = -TimelineUtils.getDistance(x, 0) * scrollSpeedMultiplier;
+          speedX = -TimelineUtils.getDistance(x, bounds) * scrollSpeedMultiplier;
         } else if (isRight) {
         } else if (isRight) {
           // Get normalized speed:
           // Get normalized speed:
-          speedX = TimelineUtils.getDistance(x, this.canvas.clientWidth) * scrollSpeedMultiplier;
+          speedX = TimelineUtils.getDistance(x, this.canvas.clientWidth - bounds) * scrollSpeedMultiplier;
           newWidth = this.scrollContainer.scrollLeft + this.canvas.clientWidth + speedX;
           newWidth = this.scrollContainer.scrollLeft + this.canvas.clientWidth + speedX;
         }
         }
 
 
         if (isTop) {
         if (isTop) {
           // Get normalized speed.
           // Get normalized speed.
-          speedY = -TimelineUtils.getDistance(x, 0) * scrollSpeedMultiplier / 4;
+          speedY = -TimelineUtils.getDistance(x, bounds) * scrollSpeedMultiplier / 4;
         } else if (isBottom) {
         } else if (isBottom) {
           // Get normalized speed:
           // Get normalized speed:
-          speedY = TimelineUtils.getDistance(x, this.canvas.clientHeight) * scrollSpeedMultiplier / 4;
+          speedY = TimelineUtils.getDistance(x, this.canvas.clientHeight - bounds) * scrollSpeedMultiplier / 4;
           newHeight = this.scrollContainer.scrollTop + this.canvas.clientHeight;
           newHeight = this.scrollContainer.scrollTop + this.canvas.clientHeight;
         }
         }
       } else {
       } else {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
lib/animation-timeline.min.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "animation-timeline-js",
   "name": "animation-timeline-js",
-  "version": "2.0.1",
+  "version": "2.0.2",
   "description": "animation timeline control based on the canvas.",
   "description": "animation timeline control based on the canvas.",
   "main": "lib/animation-timeline.min.js",
   "main": "lib/animation-timeline.min.js",
   "types": "src/index.ts",
   "types": "src/index.ts",

+ 4 - 0
src/settings/timelineConsts.ts

@@ -19,4 +19,8 @@ export class TimelineConsts {
    * Time in ms used to refresh scrollbars when pan is finished.
    * Time in ms used to refresh scrollbars when pan is finished.
    */
    */
   scrollFinishedTimeoutMs = 500;
   scrollFinishedTimeoutMs = 500;
+  /**
+   * Auto pan padding
+   */
+  autoPanByScrollPadding = 10;
 }
 }

+ 10 - 8
src/timeline.ts

@@ -795,10 +795,12 @@ export class Timeline extends TimelineEventsEmitter {
     let isChanged = false;
     let isChanged = false;
     let speedX = 0;
     let speedX = 0;
     let speedY = 0;
     let speedY = 0;
-    const isLeft = x <= 0;
-    const isRight = x >= this.canvas.clientWidth;
-    const isTop = y <= 0;
-    const isBottom = y >= this.canvas.clientHeight;
+    // Small offset to start auto pan earlier.
+    const bounds = this.consts.autoPanByScrollPadding;
+    const isLeft = x <= bounds;
+    const isRight = x >= this.canvas.clientWidth - bounds;
+    const isTop = y <= bounds;
+    const isBottom = y >= this.canvas.clientHeight - bounds;
     let newWidth = null;
     let newWidth = null;
     let newHeight = null;
     let newHeight = null;
     if (isLeft || isRight || isTop || isBottom) {
     if (isLeft || isRight || isTop || isBottom) {
@@ -812,19 +814,19 @@ export class Timeline extends TimelineEventsEmitter {
       const scrollSpeedMultiplier = isNaN(this.consts.scrollByDragSpeed) ? 1 : this.consts.scrollByDragSpeed;
       const scrollSpeedMultiplier = isNaN(this.consts.scrollByDragSpeed) ? 1 : this.consts.scrollByDragSpeed;
       if (isLeft) {
       if (isLeft) {
         // Get normalized speed.
         // Get normalized speed.
-        speedX = -TimelineUtils.getDistance(x, 0) * scrollSpeedMultiplier;
+        speedX = -TimelineUtils.getDistance(x, bounds) * scrollSpeedMultiplier;
       } else if (isRight) {
       } else if (isRight) {
         // Get normalized speed:
         // Get normalized speed:
-        speedX = TimelineUtils.getDistance(x, this.canvas.clientWidth) * scrollSpeedMultiplier;
+        speedX = TimelineUtils.getDistance(x, this.canvas.clientWidth - bounds) * scrollSpeedMultiplier;
         newWidth = this.scrollContainer.scrollLeft + this.canvas.clientWidth + speedX;
         newWidth = this.scrollContainer.scrollLeft + this.canvas.clientWidth + speedX;
       }
       }
 
 
       if (isTop) {
       if (isTop) {
         // Get normalized speed.
         // Get normalized speed.
-        speedY = (-TimelineUtils.getDistance(x, 0) * scrollSpeedMultiplier) / 4;
+        speedY = (-TimelineUtils.getDistance(x, bounds) * scrollSpeedMultiplier) / 4;
       } else if (isBottom) {
       } else if (isBottom) {
         // Get normalized speed:
         // Get normalized speed:
-        speedY = (TimelineUtils.getDistance(x, this.canvas.clientHeight) * scrollSpeedMultiplier) / 4;
+        speedY = (TimelineUtils.getDistance(x, this.canvas.clientHeight - bounds) * scrollSpeedMultiplier) / 4;
         newHeight = this.scrollContainer.scrollTop + this.canvas.clientHeight;
         newHeight = this.scrollContainer.scrollTop + this.canvas.clientHeight;
       }
       }
     } else {
     } else {

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio