timingsrc 1.1.26 → 1.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,6 +36,12 @@ const deleteTimingsrc = setTimingsrc(mediaElement, timingObject);
36
36
  deleteTimingsrc();
37
37
  ```
38
38
 
39
+ `setTimingsrc()` takes a third parameter which can be used to provide a function to modify the vector before it gets applied. It can for example be used to add a fixed offset.
40
+
41
+ ```js
42
+ setTimingsrc(mediaElement, timingObject, ({ position, ...vector }) => ({ ...vector, position: position + 5 }));
43
+ ```
44
+
39
45
  It is also possible to configure a custom version of the `setTimingsrc()` function. The following would build a `setTimingSrc()` function which does not include the fallback for stepwise updates which is necessary in Safari.
40
46
 
41
47
  ```js
@@ -1 +1 @@
1
- {"version":3,"file":"update-gradually.d.ts","sourceRoot":"","sources":["../../../src/factories/update-gradually.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD,eAAO,MAAM,qBAAqB,EAAE,uBAmBnC,CAAC"}
1
+ {"version":3,"file":"update-gradually.d.ts","sourceRoot":"","sources":["../../../src/factories/update-gradually.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD,eAAO,MAAM,qBAAqB,EAAE,uBAuBnC,CAAC"}
@@ -1,5 +1,8 @@
1
1
  export const createUpdateGradually = (timeConstant, threshold, tolerance) => {
2
2
  return ({ position, velocity }, currentTime) => {
3
+ if (velocity < 0) {
4
+ return { position, velocity: 0 };
5
+ }
3
6
  if (position < 0 || velocity === 0) {
4
7
  return { position, velocity };
5
8
  }
@@ -9,7 +12,7 @@ export const createUpdateGradually = (timeConstant, threshold, tolerance) => {
9
12
  return { position, velocity };
10
13
  }
11
14
  if (absolutePositionDifference > tolerance) {
12
- return { position: currentTime, velocity: ((timeConstant - positionDifference) / timeConstant) * velocity };
15
+ return { position: currentTime, velocity: Math.max(0, ((timeConstant - positionDifference) / timeConstant) * velocity) };
13
16
  }
14
17
  return { position: currentTime, velocity };
15
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"update-gradually.js","sourceRoot":"","sources":["../../../src/factories/update-gradually.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAA4B,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE;IACjG,OAAO,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE;QAC3C,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,KAAK,CAAC,EAAE;YAChC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;SACjC;QAED,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,CAAC;QAClD,MAAM,0BAA0B,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAEhE,IAAI,0BAA0B,GAAG,SAAS,EAAE;YACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;SACjC;QAED,IAAI,0BAA0B,GAAG,SAAS,EAAE;YACxC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC,YAAY,GAAG,kBAAkB,CAAC,GAAG,YAAY,CAAC,GAAG,QAAQ,EAAE,CAAC;SAC/G;QAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IAC/C,CAAC,CAAC;AACN,CAAC,CAAC"}
1
+ {"version":3,"file":"update-gradually.js","sourceRoot":"","sources":["../../../src/factories/update-gradually.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAA4B,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE;IACjG,OAAO,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE;QAC3C,IAAI,QAAQ,GAAG,CAAC,EAAE;YACd,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;SACpC;QAED,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,KAAK,CAAC,EAAE;YAChC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;SACjC;QAED,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,CAAC;QAClD,MAAM,0BAA0B,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAEhE,IAAI,0BAA0B,GAAG,SAAS,EAAE;YACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;SACjC;QAED,IAAI,0BAA0B,GAAG,SAAS,EAAE;YACxC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,GAAG,kBAAkB,CAAC,GAAG,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;SAC5H;QAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IAC/C,CAAC,CAAC;AACN,CAAC,CAAC"}
@@ -71,6 +71,13 @@
71
71
  var position = _ref.position,
72
72
  velocity = _ref.velocity;
73
73
 
74
+ if (velocity < 0) {
75
+ return {
76
+ position: position,
77
+ velocity: 0
78
+ };
79
+ }
80
+
74
81
  if (position < 0 || velocity === 0) {
75
82
  return {
76
83
  position: position,
@@ -91,7 +98,7 @@
91
98
  if (absolutePositionDifference > tolerance) {
92
99
  return {
93
100
  position: currentTime,
94
- velocity: (timeConstant - positionDifference) / timeConstant * velocity
101
+ velocity: Math.max(0, (timeConstant - positionDifference) / timeConstant * velocity)
95
102
  };
96
103
  }
97
104
 
package/package.json CHANGED
@@ -9,51 +9,51 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@babel/runtime": "^7.17.2",
13
- "subscribable-things": "^2.1.0",
14
- "timing-object": "^3.1.43",
15
- "tslib": "^2.3.1"
12
+ "@babel/runtime": "^7.17.9",
13
+ "subscribable-things": "^2.1.2",
14
+ "timing-object": "^3.1.44",
15
+ "tslib": "^2.4.0"
16
16
  },
17
17
  "description": "A library to synchronize a MediaElement with a TimingObject.",
18
18
  "devDependencies": {
19
- "@babel/core": "^7.17.5",
19
+ "@babel/core": "^7.17.9",
20
20
  "@babel/plugin-external-helpers": "^7.16.7",
21
21
  "@babel/plugin-transform-runtime": "^7.17.0",
22
22
  "@babel/preset-env": "^7.16.11",
23
- "@commitlint/cli": "^16.2.1",
24
- "@commitlint/config-angular": "^16.2.1",
25
- "@rollup/plugin-babel": "^5.3.0",
23
+ "@commitlint/cli": "^16.2.4",
24
+ "@commitlint/config-angular": "^16.2.4",
25
+ "@rollup/plugin-babel": "^5.3.1",
26
26
  "chai": "^4.3.6",
27
27
  "commitizen": "^4.2.4",
28
28
  "cz-conventional-changelog": "^3.3.0",
29
- "eslint": "^8.9.0",
30
- "eslint-config-holy-grail": "^52.0.2",
31
- "grunt": "^1.4.1",
29
+ "eslint": "^8.14.0",
30
+ "eslint-config-holy-grail": "^52.0.9",
31
+ "grunt": "^1.5.2",
32
32
  "grunt-cli": "^1.4.3",
33
- "grunt-contrib-clean": "^2.0.0",
33
+ "grunt-contrib-clean": "^2.0.1",
34
34
  "grunt-sh": "^0.2.0",
35
35
  "husky": "^7.0.4",
36
- "karma": "^6.3.16",
36
+ "karma": "^6.3.19",
37
37
  "karma-browserstack-launcher": "^1.6.0",
38
- "karma-chrome-launcher": "^3.1.0",
38
+ "karma-chrome-launcher": "^3.1.1",
39
39
  "karma-firefox-launcher": "^2.1.2",
40
40
  "karma-mocha": "^2.0.1",
41
41
  "karma-safari-launcher": "^1.0.0",
42
42
  "karma-sinon-chai": "^2.0.2",
43
43
  "karma-webpack": "^5.0.0",
44
44
  "load-grunt-config": "^4.0.1",
45
- "mocha": "^9.2.1",
46
- "prettier": "^2.5.1",
45
+ "mocha": "^9.2.2",
46
+ "prettier": "^2.6.2",
47
47
  "pretty-quick": "^3.1.3",
48
- "rollup": "^2.68.0",
49
- "sinon": "^11.1.2",
48
+ "rollup": "^2.70.2",
49
+ "sinon": "^13.0.2",
50
50
  "sinon-chai": "^3.7.0",
51
- "ts-loader": "^9.2.6",
52
- "tsconfig-holy-grail": "^11.1.27",
51
+ "ts-loader": "^9.2.9",
52
+ "tsconfig-holy-grail": "^11.1.30",
53
53
  "tslint": "^6.1.3",
54
- "tslint-config-holy-grail": "^53.2.26",
55
- "typescript": "^4.5.5",
56
- "webpack": "^5.69.1"
54
+ "tslint-config-holy-grail": "^53.2.28",
55
+ "typescript": "^4.6.4",
56
+ "webpack": "^5.72.0"
57
57
  },
58
58
  "files": [
59
59
  "build/es2019/",
@@ -75,5 +75,5 @@
75
75
  "test": "grunt lint && grunt test"
76
76
  },
77
77
  "types": "build/es2019/module.d.ts",
78
- "version": "1.1.26"
78
+ "version": "1.1.29"
79
79
  }
@@ -2,6 +2,10 @@ import { TUpdateGraduallyFactory } from '../types';
2
2
 
3
3
  export const createUpdateGradually: TUpdateGraduallyFactory = (timeConstant, threshold, tolerance) => {
4
4
  return ({ position, velocity }, currentTime) => {
5
+ if (velocity < 0) {
6
+ return { position, velocity: 0 };
7
+ }
8
+
5
9
  if (position < 0 || velocity === 0) {
6
10
  return { position, velocity };
7
11
  }
@@ -14,7 +18,7 @@ export const createUpdateGradually: TUpdateGraduallyFactory = (timeConstant, thr
14
18
  }
15
19
 
16
20
  if (absolutePositionDifference > tolerance) {
17
- return { position: currentTime, velocity: ((timeConstant - positionDifference) / timeConstant) * velocity };
21
+ return { position: currentTime, velocity: Math.max(0, ((timeConstant - positionDifference) / timeConstant) * velocity) };
18
22
  }
19
23
 
20
24
  return { position: currentTime, velocity };