Parcourir la source

added scroll methods.

Ievgen Naida il y a 5 ans
Parent
commit
c51ef17cdc
3 fichiers modifiés avec 31 ajouts et 1 suppressions
  1. 5 0
      index.d.ts
  2. 25 0
      index.js
  3. 1 1
      package.json

+ 5 - 0
index.d.ts

@@ -33,6 +33,11 @@ export type Timeline = {
   setLanes(data: AnimationTimelineLane[]);
   on(event: TimelineEvent, callback: SubscribeFunction);
   onScroll(callback: SubscribeFunction);
+  setScrollLeft(value: number);
+  setScrollTop(value: number);
+  getScrollLeft(): number;
+  getScrollTop(): number;
+  setLanes(data: AnimationTimelineLane[]);
   off(event: TimelineEvent, callback: Function);
   getTime(): number;
   setTime(value: number);

+ 25 - 0
index.js

@@ -1746,6 +1746,31 @@
 
 		var subscriptions = [];
 
+		this.setScrollLeft = function (value) {
+			if (scrollContainer) {
+				scrollContainer.scrollLeft = value;
+			}
+		}
+		this.setScrollTop = function (value) {
+			if (scrollContainer) {
+				scrollContainer.scrollTop = value;
+			}
+		}
+		this.getScrollLeft = function () {
+			if (scrollContainer) {
+				return scrollContainer.scrollLeft;
+			}
+
+			return 0;
+		};
+		this.getScrollTop = function () {
+			if (scrollContainer) {
+				return scrollContainer.scrollTop;
+			}
+
+			return 0;
+		};
+
 		this.onScroll = function (callback) {
 			this.on('scroll', callback);
 		}

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "animation-timeline-js",
-  "version": "1.2.1",
+  "version": "1.2.2",
   "description": "animation timeline control based on the canvas.",
   "main": "animation-timeline.js",
   "dependencies": {},