@prose-reader/core 1.87.0 → 1.89.0

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.
@@ -1048,6 +1048,26 @@
1048
1048
  rxjs.distinctUntilChanged(shared.isShallowEqual)
1049
1049
  );
1050
1050
  };
1051
+ const throttleLock = ({ reader, duration }) => (stream) => {
1052
+ let unlockFn = void 0;
1053
+ const unlock = () => {
1054
+ unlockFn == null ? void 0 : unlockFn();
1055
+ unlockFn = void 0;
1056
+ };
1057
+ return stream.pipe(
1058
+ rxjs.tap(() => {
1059
+ if (!unlockFn) {
1060
+ unlockFn = reader == null ? void 0 : reader.navigation.lock();
1061
+ }
1062
+ }),
1063
+ rxjs.throttleTime(duration, rxjs.animationFrameScheduler, {
1064
+ trailing: true,
1065
+ leading: true
1066
+ }),
1067
+ rxjs.tap(unlock),
1068
+ rxjs.finalize(unlock)
1069
+ );
1070
+ };
1051
1071
  const navigationEnhancer = (next) => (options) => {
1052
1072
  const reader = next(options);
1053
1073
  const state$ = observeState(reader);
@@ -1066,6 +1086,7 @@
1066
1086
  navigation: {
1067
1087
  ...reader.navigation,
1068
1088
  state$,
1089
+ throttleLock: ({ duration, trigger }) => trigger.pipe(throttleLock({ duration, reader })),
1069
1090
  moveTo: panNavigator.moveTo.bind(panNavigator),
1070
1091
  turnBottom: manualNavigator.turnBottom.bind(manualNavigator),
1071
1092
  turnTop: manualNavigator.turnTop.bind(manualNavigator),