Browse Source

consts become interface

Ievgen Naida 5 years ago
parent
commit
266f8a87b7

+ 37 - 18
lib/animation-timeline.js

@@ -183,7 +183,7 @@ __webpack_require__.d(__webpack_exports__, "TimelineScrollEvent", function() { r
 __webpack_require__.d(__webpack_exports__, "TimelineClickEvent", function() { return /* reexport */ TimelineClickEvent; });
 __webpack_require__.d(__webpack_exports__, "TimelineDragEvent", function() { return /* reexport */ TimelineDragEvent; });
 __webpack_require__.d(__webpack_exports__, "TimelineEvents", function() { return /* reexport */ TimelineEvents; });
-__webpack_require__.d(__webpack_exports__, "TimelineConsts", function() { return /* reexport */ TimelineConsts; });
+__webpack_require__.d(__webpack_exports__, "TimelineConsts", function() { return /* reexport */ /* Cannot get final name for export "TimelineConsts" in "./src/settings/timelineConsts.ts" (known exports: defaultTimelineConsts, known reexports: ) */ undefined; });
 __webpack_require__.d(__webpack_exports__, "TimelineKeyframeShape", function() { return /* reexport */ TimelineKeyframeShape; });
 __webpack_require__.d(__webpack_exports__, "TimelineInteractionMode", function() { return /* reexport */ TimelineInteractionMode; });
 __webpack_require__.d(__webpack_exports__, "TimelineElementType", function() { return /* reexport */ TimelineElementType; });
@@ -531,26 +531,41 @@ var timelineOptions_TimelineOptions = function TimelineOptions() {
   timelineOptions_defineProperty(this, "keyframesDraggable", true);
 };
 // CONCATENATED MODULE: ./src/settings/timelineConsts.ts
-function timelineConsts_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function timelineConsts_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
-var TimelineConsts = function TimelineConsts() {
-  timelineConsts_classCallCheck(this, TimelineConsts);
-
-  timelineConsts_defineProperty(this, "autoPanSpeed", 50);
+var defaultTimelineConsts = {
+  /**
+   * Auto pan speed.
+   */
+  autoPanSpeed: 50,
 
-  timelineConsts_defineProperty(this, "scrollByDragSpeed", 0.12);
+  /**
+   * scroll speed when mouse drag is used (from 0 to 1)
+   */
+  scrollByDragSpeed: 0.12,
 
-  timelineConsts_defineProperty(this, "clickDetectionMs", 120);
+  /**
+   * Determine whether item was clicked.
+   */
+  clickDetectionMs: 120,
 
-  timelineConsts_defineProperty(this, "doubleClickTimeoutMs", 400);
+  /**
+   * Timeout to detect double click.
+   */
+  doubleClickTimeoutMs: 400,
 
-  timelineConsts_defineProperty(this, "scrollFinishedTimeoutMs", 500);
+  /**
+   * Time in ms used to refresh scrollbars when pan is finished.
+   */
+  scrollFinishedTimeoutMs: 500,
 
-  timelineConsts_defineProperty(this, "autoPanByScrollPadding", 10);
+  /**
+   * Auto pan padding
+   */
+  autoPanByScrollPadding: 10,
 
-  timelineConsts_defineProperty(this, "clickThreshold", 3);
+  /**
+   * Click threshold
+   */
+  clickThreshold: 3
 };
 // CONCATENATED MODULE: ./src/enums/timelineCursorType.ts
 var TimelineCursorType;
@@ -944,7 +959,7 @@ var timeline_Timeline = /*#__PURE__*/function (_TimelineEventsEmitte) {
 
     timeline_defineProperty(timeline_assertThisInitialized(_this), "_lastClickPoint", null);
 
-    timeline_defineProperty(timeline_assertThisInitialized(_this), "_consts", new TimelineConsts());
+    timeline_defineProperty(timeline_assertThisInitialized(_this), "_consts", defaultTimelineConsts);
 
     timeline_defineProperty(timeline_assertThisInitialized(_this), "_clickAllowed", false);
 
@@ -1027,7 +1042,10 @@ var timeline_Timeline = /*#__PURE__*/function (_TimelineEventsEmitte) {
           var mousePos = _this._getMousePos(_this._canvas, event);
 
           var x = mousePos.x;
-          if (x <= 0) x = 0;
+
+          if (x <= 0) {
+            x = 0;
+          }
 
           var val = _this.pxToVal(_this._scrollContainer.scrollLeft + x, false);
 
@@ -1056,7 +1074,8 @@ var timeline_Timeline = /*#__PURE__*/function (_TimelineEventsEmitte) {
           _this._rescaleInternal(newScrollLeft + _this._canvas.clientWidth, null, 'zoom');
 
           if (_this._scrollContainer.scrollLeft != newScrollLeft) {
-            _this._scrollContainer.scrollLeft = newScrollLeft; // Scroll event will redraw the screen.
+            // Scroll event will redraw the screen.
+            _this._scrollContainer.scrollLeft = newScrollLeft;
           }
 
           _this.redraw();

File diff suppressed because it is too large
+ 0 - 0
lib/animation-timeline.min.js


+ 2 - 1
lib/settings/timelineConsts.d.ts

@@ -1,4 +1,4 @@
-export declare class TimelineConsts {
+export interface TimelineConsts {
     /**
      * Auto pan speed.
      */
@@ -28,3 +28,4 @@ export declare class TimelineConsts {
      */
     clickThreshold: number;
 }
+export declare const defaultTimelineConsts: TimelineConsts;

+ 38 - 8
src/settings/timelineConsts.ts

@@ -1,30 +1,60 @@
-export class TimelineConsts {
+export interface TimelineConsts {
   /**
    * Auto pan speed.
    */
-  autoPanSpeed = 50;
+  autoPanSpeed: number;
   /**
    * scroll speed when mouse drag is used (from 0 to 1)
    */
-  scrollByDragSpeed = 0.12;
+  scrollByDragSpeed: number;
   /**
    * Determine whether item was clicked.
    */
-  clickDetectionMs = 120;
+  clickDetectionMs: number;
   /**
    * Timeout to detect double click.
    */
-  doubleClickTimeoutMs = 400;
+  doubleClickTimeoutMs: number;
   /**
    * Time in ms used to refresh scrollbars when pan is finished.
    */
-  scrollFinishedTimeoutMs = 500;
+  scrollFinishedTimeoutMs: number;
   /**
    * Auto pan padding
    */
-  autoPanByScrollPadding = 10;
+  autoPanByScrollPadding: number;
   /**
    * Click threshold
    */
-  clickThreshold = 3;
+  clickThreshold: number;
 }
+export const defaultTimelineConsts = {
+  /**
+   * Auto pan speed.
+   */
+  autoPanSpeed: 50,
+  /**
+   * scroll speed when mouse drag is used (from 0 to 1)
+   */
+  scrollByDragSpeed: 0.12,
+  /**
+   * Determine whether item was clicked.
+   */
+  clickDetectionMs: 120,
+  /**
+   * Timeout to detect double click.
+   */
+  doubleClickTimeoutMs: 400,
+  /**
+   * Time in ms used to refresh scrollbars when pan is finished.
+   */
+  scrollFinishedTimeoutMs: 500,
+  /**
+   * Auto pan padding
+   */
+  autoPanByScrollPadding: 10,
+  /**
+   * Click threshold
+   */
+  clickThreshold: 3,
+} as TimelineConsts;

+ 6 - 4
src/timeline.ts

@@ -1,7 +1,7 @@
 import { TimelineEventsEmitter } from './timelineEventsEmitter';
 import { TimelineUtils } from './utils/timelineUtils';
 import { TimelineOptions } from './settings/timelineOptions';
-import { TimelineConsts } from './settings/timelineConsts';
+import { defaultTimelineConsts, TimelineConsts } from './settings/timelineConsts';
 import { TimelineKeyframe } from './timelineKeyframe';
 import { TimelineModel } from './timelineModel';
 import { TimelineClickableElement } from './utils/timelineClickableElement';
@@ -73,7 +73,7 @@ export class Timeline extends TimelineEventsEmitter {
   _clickTimeout? = 0;
   _lastClickTime = 0;
   _lastClickPoint: DOMPoint | null = null;
-  _consts = new TimelineConsts();
+  _consts: TimelineConsts = defaultTimelineConsts;
   _clickAllowed = false;
   /**
    * scroll finished timer reference.
@@ -292,7 +292,9 @@ export class Timeline extends TimelineEventsEmitter {
       if (this._options.zoomSpeed > 0 && this._options.zoomSpeed <= 1) {
         const mousePos = this._getMousePos(this._canvas, event);
         let x = mousePos.x;
-        if (x <= 0) x = 0;
+        if (x <= 0) {
+          x = 0;
+        }
         const val = this.pxToVal(this._scrollContainer.scrollLeft + x, false);
         const diff = this._canvas.clientWidth / x;
 
@@ -312,8 +314,8 @@ export class Timeline extends TimelineEventsEmitter {
 
         this._rescaleInternal(newScrollLeft + this._canvas.clientWidth, null, 'zoom');
         if (this._scrollContainer.scrollLeft != newScrollLeft) {
-          this._scrollContainer.scrollLeft = newScrollLeft;
           // Scroll event will redraw the screen.
+          this._scrollContainer.scrollLeft = newScrollLeft;
         }
 
         this.redraw();

+ 1 - 1
tests/unittests.html

@@ -10,7 +10,7 @@
 
 <body>
     <div>
-        <a href="../demo/index.html">back</a>
+        <a href="../index.html">Back</a>
     </div>
     <div id="mocha"></div>
 

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