@helpdice/draggable 0.0.0-stage → 0.0.2
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/LICENSE +13 -0
- package/README.md +164 -2
- package/dist/draggable.cjs.js +9925 -0
- package/dist/draggable.cjs.js.map +1 -0
- package/dist/draggable.esm.js +9899 -0
- package/dist/draggable.esm.js.map +1 -0
- package/dist/types/animation.d.ts +31 -0
- package/dist/types/debug/middleware/action-timing-average.d.ts +3 -0
- package/dist/types/debug/middleware/action-timing.d.ts +3 -0
- package/dist/types/debug/middleware/log.d.ts +4 -0
- package/dist/types/debug/middleware/user-timing.d.ts +3 -0
- package/dist/types/debug/timings.d.ts +3 -0
- package/dist/types/dev-warning.d.ts +4 -0
- package/dist/types/empty.d.ts +2 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/invariant.d.ts +4 -0
- package/dist/types/native-with-fallback.d.ts +10 -0
- package/dist/types/screen-reader-message-preset.d.ts +9 -0
- package/dist/types/state/action-creators.d.ts +158 -0
- package/dist/types/state/auto-scroller/auto-scroller-types.d.ts +6 -0
- package/dist/types/state/auto-scroller/can-scroll.d.ts +19 -0
- package/dist/types/state/auto-scroller/fluid-scroller/config.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/did-start-in-scrollable-area.d.ts +0 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-best-scrollable-droppable.d.ts +9 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-droppable-scroll-change.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-percentage.d.ts +7 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/adjust-for-size-limits.d.ts +8 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/dampen-value-by-time.d.ts +2 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-distance-thresholds.d.ts +8 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value-from-distance.d.ts +3 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value.d.ts +9 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/index.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/min-scroll.d.ts +2 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-scroll/index.d.ts +10 -0
- package/dist/types/state/auto-scroller/fluid-scroller/get-window-scroll-change.d.ts +11 -0
- package/dist/types/state/auto-scroller/fluid-scroller/index.d.ts +13 -0
- package/dist/types/state/auto-scroller/fluid-scroller/scroll.d.ts +11 -0
- package/dist/types/state/auto-scroller/index.d.ts +11 -0
- package/dist/types/state/auto-scroller/jump-scroller.d.ts +11 -0
- package/dist/types/state/axis.d.ts +3 -0
- package/dist/types/state/calculate-drag-impact/calculate-reorder-impact.d.ts +13 -0
- package/dist/types/state/can-start-drag.d.ts +3 -0
- package/dist/types/state/create-store.d.ts +16 -0
- package/dist/types/state/did-start-after-critical.d.ts +2 -0
- package/dist/types/state/dimension-marshal/dimension-marshal-types.d.ts +23 -0
- package/dist/types/state/dimension-marshal/dimension-marshal.d.ts +4 -0
- package/dist/types/state/dimension-marshal/get-initial-publish.d.ts +10 -0
- package/dist/types/state/dimension-marshal/while-dragging-publisher.d.ts +17 -0
- package/dist/types/state/dimension-structures.d.ts +5 -0
- package/dist/types/state/droppable/get-droppable.d.ts +21 -0
- package/dist/types/state/droppable/is-home-of.d.ts +3 -0
- package/dist/types/state/droppable/scroll-droppable.d.ts +4 -0
- package/dist/types/state/droppable/should-use-placeholder.d.ts +3 -0
- package/dist/types/state/droppable/util/clip.d.ts +3 -0
- package/dist/types/state/droppable/util/get-subject.d.ts +10 -0
- package/dist/types/state/droppable/what-is-dragged-over-from-result.d.ts +3 -0
- package/dist/types/state/droppable/what-is-dragged-over.d.ts +3 -0
- package/dist/types/state/droppable/with-placeholder.d.ts +3 -0
- package/dist/types/state/get-center-from-impact/get-client-border-box-center/get-client-from-page-border-box-center.d.ts +9 -0
- package/dist/types/state/get-center-from-impact/get-client-border-box-center/index.d.ts +12 -0
- package/dist/types/state/get-center-from-impact/get-page-border-box-center/index.d.ts +11 -0
- package/dist/types/state/get-center-from-impact/get-page-border-box-center/when-combining.d.ts +9 -0
- package/dist/types/state/get-center-from-impact/get-page-border-box-center/when-reordering.d.ts +11 -0
- package/dist/types/state/get-center-from-impact/move-relative-to.d.ts +16 -0
- package/dist/types/state/get-combined-item-displacement.d.ts +10 -0
- package/dist/types/state/get-displaced-by.d.ts +4 -0
- package/dist/types/state/get-displacement-groups.d.ts +12 -0
- package/dist/types/state/get-drag-impact/get-combine-impact.d.ts +13 -0
- package/dist/types/state/get-drag-impact/get-reorder-impact.d.ts +13 -0
- package/dist/types/state/get-drag-impact/index.d.ts +13 -0
- package/dist/types/state/get-draggables-inside-droppable.d.ts +3 -0
- package/dist/types/state/get-droppable-over.d.ts +9 -0
- package/dist/types/state/get-frame.d.ts +3 -0
- package/dist/types/state/get-home-location.d.ts +3 -0
- package/dist/types/state/get-impact-location.d.ts +3 -0
- package/dist/types/state/get-is-displaced.d.ts +7 -0
- package/dist/types/state/get-lift-effect.d.ts +13 -0
- package/dist/types/state/get-max-scroll.d.ts +9 -0
- package/dist/types/state/is-movement-allowed.d.ts +2 -0
- package/dist/types/state/is-within.d.ts +2 -0
- package/dist/types/state/middleware/auto-scroll.d.ts +4 -0
- package/dist/types/state/middleware/dimension-marshal-stopper.d.ts +4 -0
- package/dist/types/state/middleware/drop/drop-animation-finish-middleware.d.ts +3 -0
- package/dist/types/state/middleware/drop/drop-animation-flush-on-scroll-middleware.d.ts +3 -0
- package/dist/types/state/middleware/drop/drop-middleware.d.ts +3 -0
- package/dist/types/state/middleware/drop/get-drop-duration.d.ts +9 -0
- package/dist/types/state/middleware/drop/get-drop-impact.d.ts +16 -0
- package/dist/types/state/middleware/drop/get-new-home-client-offset.d.ts +11 -0
- package/dist/types/state/middleware/drop/index.d.ts +1 -0
- package/dist/types/state/middleware/focus.d.ts +4 -0
- package/dist/types/state/middleware/lift.d.ts +4 -0
- package/dist/types/state/middleware/pending-drop.d.ts +3 -0
- package/dist/types/state/middleware/responders/async-marshal.d.ts +9 -0
- package/dist/types/state/middleware/responders/expiring-announce.d.ts +6 -0
- package/dist/types/state/middleware/responders/index.d.ts +1 -0
- package/dist/types/state/middleware/responders/is-equal.d.ts +4 -0
- package/dist/types/state/middleware/responders/publisher.d.ts +17 -0
- package/dist/types/state/middleware/responders/responders-middleware.d.ts +4 -0
- package/dist/types/state/middleware/scroll-listener.d.ts +3 -0
- package/dist/types/state/middleware/style.d.ts +4 -0
- package/dist/types/state/middleware/util/validate-dimensions.d.ts +2 -0
- package/dist/types/state/move-in-direction/index.d.ts +8 -0
- package/dist/types/state/move-in-direction/move-cross-axis/get-best-cross-axis-droppable.d.ts +11 -0
- package/dist/types/state/move-in-direction/move-cross-axis/get-closest-draggable.d.ts +11 -0
- package/dist/types/state/move-in-direction/move-cross-axis/index.d.ts +15 -0
- package/dist/types/state/move-in-direction/move-cross-axis/move-to-new-droppable.d.ts +14 -0
- package/dist/types/state/move-in-direction/move-cross-axis/without-starting-displacement.d.ts +4 -0
- package/dist/types/state/move-in-direction/move-in-direction-types.d.ts +7 -0
- package/dist/types/state/move-in-direction/move-to-next-place/index.d.ts +16 -0
- package/dist/types/state/move-in-direction/move-to-next-place/is-totally-visible-in-new-location.d.ts +12 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-combine/index.d.ts +10 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-index/from-combine.d.ts +11 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-index/from-reorder.d.ts +9 -0
- package/dist/types/state/move-in-direction/move-to-next-place/move-to-next-index/index.d.ts +14 -0
- package/dist/types/state/no-impact.d.ts +6 -0
- package/dist/types/state/patch-dimension-map.d.ts +3 -0
- package/dist/types/state/patch-droppable-map.d.ts +3 -0
- package/dist/types/state/position.d.ts +10 -0
- package/dist/types/state/post-reducer/when-moving/refresh-snap.d.ts +8 -0
- package/dist/types/state/post-reducer/when-moving/update.d.ts +12 -0
- package/dist/types/state/publish-while-dragging-in-virtual/adjust-additions-for-scroll-changes.d.ts +8 -0
- package/dist/types/state/publish-while-dragging-in-virtual/index.d.ts +7 -0
- package/dist/types/state/publish-while-dragging-in-virtual/offset-draggable.d.ts +9 -0
- package/dist/types/state/recompute-placeholders.d.ts +10 -0
- package/dist/types/state/rect.d.ts +2 -0
- package/dist/types/state/reducer.d.ts +5 -0
- package/dist/types/state/registry/create-registry.d.ts +2 -0
- package/dist/types/state/registry/registry-types.d.ts +62 -0
- package/dist/types/state/registry/use-registry.d.ts +2 -0
- package/dist/types/state/remove-draggable-from-list.d.ts +3 -0
- package/dist/types/state/scroll-viewport.d.ts +4 -0
- package/dist/types/state/spacing.d.ts +6 -0
- package/dist/types/state/store-types.d.ts +10 -0
- package/dist/types/state/update-displacement-visibility/recompute.d.ts +10 -0
- package/dist/types/state/update-displacement-visibility/speculatively-increase.d.ts +11 -0
- package/dist/types/state/visibility/is-partially-visible-through-frame.d.ts +3 -0
- package/dist/types/state/visibility/is-position-in-frame.d.ts +2 -0
- package/dist/types/state/visibility/is-totally-visible-through-frame-on-axis.d.ts +4 -0
- package/dist/types/state/visibility/is-totally-visible-through-frame.d.ts +3 -0
- package/dist/types/state/visibility/is-visible.d.ts +13 -0
- package/dist/types/state/with-scroll-change/with-all-displacement.d.ts +4 -0
- package/dist/types/state/with-scroll-change/with-droppable-displacement.d.ts +4 -0
- package/dist/types/state/with-scroll-change/with-droppable-scroll.d.ts +4 -0
- package/dist/types/state/with-scroll-change/with-viewport-displacement.d.ts +4 -0
- package/dist/types/types.d.ts +323 -0
- package/dist/types/view/animate-in-out/animate-in-out.d.ts +24 -0
- package/dist/types/view/animate-in-out/index.d.ts +1 -0
- package/dist/types/view/check-is-valid-inner-ref.d.ts +1 -0
- package/dist/types/view/context/app-context.d.ts +16 -0
- package/dist/types/view/context/droppable-context.d.ts +9 -0
- package/dist/types/view/context/hooks.d.ts +3 -0
- package/dist/types/view/context/store-context.d.ts +4 -0
- package/dist/types/view/data-attributes.d.ts +22 -0
- package/dist/types/view/drag-drop-context/app.d.ts +13 -0
- package/dist/types/view/drag-drop-context/check-doctype.d.ts +2 -0
- package/dist/types/view/drag-drop-context/check-react-version.d.ts +2 -0
- package/dist/types/view/drag-drop-context/drag-drop-context-types.d.ts +5 -0
- package/dist/types/view/drag-drop-context/drag-drop-context.d.ts +12 -0
- package/dist/types/view/drag-drop-context/error-boundary.d.ts +20 -0
- package/dist/types/view/drag-drop-context/index.d.ts +1 -0
- package/dist/types/view/drag-drop-context/use-startup-validation.d.ts +1 -0
- package/dist/types/view/drag-drop-context/use-unique-context-id.d.ts +3 -0
- package/dist/types/view/draggable/connected-draggable.d.ts +5 -0
- package/dist/types/view/draggable/draggable-api.d.ts +3 -0
- package/dist/types/view/draggable/draggable-types.d.ts +106 -0
- package/dist/types/view/draggable/draggable.d.ts +2 -0
- package/dist/types/view/draggable/get-style.d.ts +3 -0
- package/dist/types/view/draggable/index.d.ts +1 -0
- package/dist/types/view/draggable/use-validation.d.ts +4 -0
- package/dist/types/view/droppable/connected-droppable.d.ts +7 -0
- package/dist/types/view/droppable/droppable-types.d.ts +50 -0
- package/dist/types/view/droppable/droppable.d.ts +2 -0
- package/dist/types/view/droppable/index.d.ts +1 -0
- package/dist/types/view/droppable/use-validation.d.ts +8 -0
- package/dist/types/view/event-bindings/bind-events.d.ts +2 -0
- package/dist/types/view/event-bindings/event-types.d.ts +10 -0
- package/dist/types/view/get-body-element.d.ts +2 -0
- package/dist/types/view/get-border-box-center-position.d.ts +3 -0
- package/dist/types/view/get-document-element.d.ts +2 -0
- package/dist/types/view/get-elements/find-drag-handle.d.ts +2 -0
- package/dist/types/view/get-elements/find-draggable.d.ts +2 -0
- package/dist/types/view/is-strict-equal.d.ts +2 -0
- package/dist/types/view/is-type-of-element/is-element.d.ts +1 -0
- package/dist/types/view/is-type-of-element/is-html-element.d.ts +1 -0
- package/dist/types/view/is-type-of-element/is-svg-element.d.ts +1 -0
- package/dist/types/view/key-codes.d.ts +12 -0
- package/dist/types/view/placeholder/index.d.ts +1 -0
- package/dist/types/view/placeholder/placeholder-types.d.ts +14 -0
- package/dist/types/view/placeholder/placeholder.d.ts +28 -0
- package/dist/types/view/scroll-listener.d.ts +12 -0
- package/dist/types/view/throw-if-invalid-inner-ref.d.ts +2 -0
- package/dist/types/view/use-announcer/index.d.ts +1 -0
- package/dist/types/view/use-announcer/use-announcer.d.ts +3 -0
- package/dist/types/view/use-dev-setup-warning.d.ts +1 -0
- package/dist/types/view/use-dev.d.ts +1 -0
- package/dist/types/view/use-draggable-publisher/get-dimension.d.ts +3 -0
- package/dist/types/view/use-draggable-publisher/index.d.ts +1 -0
- package/dist/types/view/use-draggable-publisher/use-draggable-publisher.d.ts +8 -0
- package/dist/types/view/use-droppable-publisher/check-for-nested-scroll-container.d.ts +2 -0
- package/dist/types/view/use-droppable-publisher/get-closest-scrollable.d.ts +2 -0
- package/dist/types/view/use-droppable-publisher/get-dimension.d.ts +15 -0
- package/dist/types/view/use-droppable-publisher/get-env.d.ts +6 -0
- package/dist/types/view/use-droppable-publisher/get-listener-options.d.ts +5 -0
- package/dist/types/view/use-droppable-publisher/get-scroll.d.ts +3 -0
- package/dist/types/view/use-droppable-publisher/index.d.ts +1 -0
- package/dist/types/view/use-droppable-publisher/is-in-fixed-container.d.ts +2 -0
- package/dist/types/view/use-droppable-publisher/use-droppable-publisher.d.ts +13 -0
- package/dist/types/view/use-focus-marshal/focus-marshal-types.d.ts +9 -0
- package/dist/types/view/use-focus-marshal/index.d.ts +1 -0
- package/dist/types/view/use-focus-marshal/use-focus-marshal.d.ts +3 -0
- package/dist/types/view/use-hidden-text-element/index.d.ts +1 -0
- package/dist/types/view/use-hidden-text-element/use-hidden-text-element.d.ts +12 -0
- package/dist/types/view/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/types/view/use-previous-ref.d.ts +1 -0
- package/dist/types/view/use-required-context.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/closest.d.ts +1 -0
- package/dist/types/view/use-sensor-marshal/find-closest-draggable-id-from-event.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/index.d.ts +4 -0
- package/dist/types/view/use-sensor-marshal/is-event-in-interactive-element.d.ts +5 -0
- package/dist/types/view/use-sensor-marshal/lock.d.ts +11 -0
- package/dist/types/view/use-sensor-marshal/sensors/use-keyboard-sensor.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/sensors/use-mouse-sensor.d.ts +4 -0
- package/dist/types/view/use-sensor-marshal/sensors/use-touch-sensor.d.ts +4 -0
- package/dist/types/view/use-sensor-marshal/sensors/util/prevent-standard-key-events.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/sensors/util/supported-page-visibility-event-name.d.ts +2 -0
- package/dist/types/view/use-sensor-marshal/use-sensor-marshal.d.ts +12 -0
- package/dist/types/view/use-sensor-marshal/use-validate-sensor-hooks.d.ts +2 -0
- package/dist/types/view/use-style-marshal/get-styles.d.ts +10 -0
- package/dist/types/view/use-style-marshal/index.d.ts +1 -0
- package/dist/types/view/use-style-marshal/style-marshal-types.d.ts +6 -0
- package/dist/types/view/use-style-marshal/use-style-marshal.d.ts +3 -0
- package/dist/types/view/use-unique-id.d.ts +7 -0
- package/dist/types/view/visually-hidden-style.d.ts +2 -0
- package/dist/types/view/window/get-max-window-scroll.d.ts +3 -0
- package/dist/types/view/window/get-viewport.d.ts +3 -0
- package/dist/types/view/window/get-window-from-el.d.ts +2 -0
- package/dist/types/view/window/get-window-scroll.d.ts +3 -0
- package/dist/types/view/window/scroll-window.d.ts +3 -0
- package/package.json +157 -4
- package/src/animation.ts +75 -0
- package/src/debug/middleware/action-timing-average.ts +52 -0
- package/src/debug/middleware/action-timing.ts +16 -0
- package/src/debug/middleware/log.ts +26 -0
- package/src/debug/middleware/user-timing.ts +16 -0
- package/src/debug/timings.ts +87 -0
- package/src/dev-warning.ts +50 -0
- package/src/empty.ts +6 -0
- package/src/index.ts +67 -0
- package/src/invariant.ts +64 -0
- package/src/native-with-fallback.ts +69 -0
- package/src/screen-reader-message-preset.ts +135 -0
- package/src/state/action-creators.ts +358 -0
- package/src/state/auto-scroller/auto-scroller-types.ts +8 -0
- package/src/state/auto-scroller/can-scroll.ts +320 -0
- package/src/state/auto-scroller/fluid-scroller/config.ts +25 -0
- package/src/state/auto-scroller/fluid-scroller/did-start-in-scrollable-area.ts +1 -0
- package/src/state/auto-scroller/fluid-scroller/get-best-scrollable-droppable.ts +77 -0
- package/src/state/auto-scroller/fluid-scroller/get-droppable-scroll-change.ts +39 -0
- package/src/state/auto-scroller/fluid-scroller/get-percentage.ts +25 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/adjust-for-size-limits.ts +30 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/dampen-value-by-time.ts +37 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-distance-thresholds.ts +25 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value-from-distance.ts +61 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/get-value.ts +39 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/index.ts +46 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/get-scroll-on-axis/min-scroll.ts +4 -0
- package/src/state/auto-scroller/fluid-scroller/get-scroll/index.ts +76 -0
- package/src/state/auto-scroller/fluid-scroller/get-window-scroll-change.ts +31 -0
- package/src/state/auto-scroller/fluid-scroller/index.ts +91 -0
- package/src/state/auto-scroller/fluid-scroller/scroll.ts +72 -0
- package/src/state/auto-scroller/index.ts +56 -0
- package/src/state/auto-scroller/jump-scroller.ts +140 -0
- package/src/state/axis.ts +26 -0
- package/src/state/calculate-drag-impact/calculate-reorder-impact.ts +138 -0
- package/src/state/can-start-drag.ts +29 -0
- package/src/state/create-store.ts +98 -0
- package/src/state/did-start-after-critical.ts +9 -0
- package/src/state/dimension-marshal/dimension-marshal-types.ts +49 -0
- package/src/state/dimension-marshal/dimension-marshal.ts +219 -0
- package/src/state/dimension-marshal/get-initial-publish.ts +66 -0
- package/src/state/dimension-marshal/while-dragging-publisher.ts +146 -0
- package/src/state/dimension-structures.ts +35 -0
- package/src/state/droppable/get-droppable.ts +103 -0
- package/src/state/droppable/is-home-of.ts +7 -0
- package/src/state/droppable/scroll-droppable.ts +53 -0
- package/src/state/droppable/should-use-placeholder.ts +7 -0
- package/src/state/droppable/util/clip.ts +17 -0
- package/src/state/droppable/util/get-subject.ts +63 -0
- package/src/state/droppable/what-is-dragged-over-from-result.ts +16 -0
- package/src/state/droppable/what-is-dragged-over.ts +16 -0
- package/src/state/droppable/with-placeholder.ts +174 -0
- package/src/state/get-center-from-impact/get-client-border-box-center/get-client-from-page-border-box-center.ts +30 -0
- package/src/state/get-center-from-impact/get-client-border-box-center/index.ts +45 -0
- package/src/state/get-center-from-impact/get-page-border-box-center/index.ts +71 -0
- package/src/state/get-center-from-impact/get-page-border-box-center/when-combining.ts +40 -0
- package/src/state/get-center-from-impact/get-page-border-box-center/when-reordering.ts +113 -0
- package/src/state/get-center-from-impact/move-relative-to.ts +68 -0
- package/src/state/get-combined-item-displacement.ts +35 -0
- package/src/state/get-displaced-by.ts +17 -0
- package/src/state/get-displacement-groups.ts +131 -0
- package/src/state/get-drag-impact/get-combine-impact.ts +131 -0
- package/src/state/get-drag-impact/get-reorder-impact.ts +145 -0
- package/src/state/get-drag-impact/index.ts +94 -0
- package/src/state/get-draggables-inside-droppable.ts +31 -0
- package/src/state/get-droppable-over.ts +161 -0
- package/src/state/get-frame.ts +10 -0
- package/src/state/get-home-location.ts +7 -0
- package/src/state/get-impact-location.ts +16 -0
- package/src/state/get-is-displaced.ts +12 -0
- package/src/state/get-lift-effect.ts +84 -0
- package/src/state/get-max-scroll.ts +32 -0
- package/src/state/is-movement-allowed.ts +13 -0
- package/src/state/is-within.ts +9 -0
- package/src/state/middleware/auto-scroll.ts +38 -0
- package/src/state/middleware/dimension-marshal-stopper.ts +20 -0
- package/src/state/middleware/drop/drop-animation-finish-middleware.ts +21 -0
- package/src/state/middleware/drop/drop-animation-flush-on-scroll-middleware.ts +63 -0
- package/src/state/middleware/drop/drop-middleware.ts +146 -0
- package/src/state/middleware/drop/get-drop-duration.ts +48 -0
- package/src/state/middleware/drop/get-drop-impact.ts +79 -0
- package/src/state/middleware/drop/get-new-home-client-offset.ts +55 -0
- package/src/state/middleware/drop/index.ts +2 -0
- package/src/state/middleware/focus.ts +42 -0
- package/src/state/middleware/lift.ts +66 -0
- package/src/state/middleware/pending-drop.ts +37 -0
- package/src/state/middleware/responders/async-marshal.ts +58 -0
- package/src/state/middleware/responders/expiring-announce.ts +44 -0
- package/src/state/middleware/responders/index.ts +2 -0
- package/src/state/middleware/responders/is-equal.ts +57 -0
- package/src/state/middleware/responders/publisher.ts +255 -0
- package/src/state/middleware/responders/responders-middleware.ts +81 -0
- package/src/state/middleware/scroll-listener.ts +31 -0
- package/src/state/middleware/style.ts +22 -0
- package/src/state/middleware/util/validate-dimensions.ts +71 -0
- package/src/state/move-in-direction/index.ts +85 -0
- package/src/state/move-in-direction/move-cross-axis/get-best-cross-axis-droppable.ts +169 -0
- package/src/state/move-in-direction/move-cross-axis/get-closest-draggable.ts +80 -0
- package/src/state/move-in-direction/move-cross-axis/index.ts +110 -0
- package/src/state/move-in-direction/move-cross-axis/move-to-new-droppable.ts +122 -0
- package/src/state/move-in-direction/move-cross-axis/without-starting-displacement.ts +31 -0
- package/src/state/move-in-direction/move-in-direction-types.ts +10 -0
- package/src/state/move-in-direction/move-to-next-place/index.ts +133 -0
- package/src/state/move-in-direction/move-to-next-place/is-totally-visible-in-new-location.ts +53 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-combine/index.ts +98 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-index/from-combine.ts +53 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-index/from-reorder.ts +44 -0
- package/src/state/move-in-direction/move-to-next-place/move-to-next-index/index.ts +87 -0
- package/src/state/no-impact.ts +33 -0
- package/src/state/patch-dimension-map.ts +11 -0
- package/src/state/patch-droppable-map.ts +10 -0
- package/src/state/position.ts +65 -0
- package/src/state/post-reducer/when-moving/refresh-snap.ts +68 -0
- package/src/state/post-reducer/when-moving/update.ts +121 -0
- package/src/state/publish-while-dragging-in-virtual/adjust-additions-for-scroll-changes.ts +59 -0
- package/src/state/publish-while-dragging-in-virtual/index.ts +159 -0
- package/src/state/publish-while-dragging-in-virtual/offset-draggable.ts +36 -0
- package/src/state/recompute-placeholders.ts +101 -0
- package/src/state/rect.ts +7 -0
- package/src/state/reducer.ts +467 -0
- package/src/state/registry/create-registry.ts +162 -0
- package/src/state/registry/registry-types.ts +106 -0
- package/src/state/registry/use-registry.ts +20 -0
- package/src/state/remove-draggable-from-list.ts +13 -0
- package/src/state/scroll-viewport.ts +34 -0
- package/src/state/spacing.ts +45 -0
- package/src/state/store-types.ts +19 -0
- package/src/state/update-displacement-visibility/recompute.ts +55 -0
- package/src/state/update-displacement-visibility/speculatively-increase.ts +112 -0
- package/src/state/visibility/is-partially-visible-through-frame.ts +60 -0
- package/src/state/visibility/is-position-in-frame.ts +12 -0
- package/src/state/visibility/is-totally-visible-through-frame-on-axis.ts +19 -0
- package/src/state/visibility/is-totally-visible-through-frame.ts +18 -0
- package/src/state/visibility/is-visible.ts +102 -0
- package/src/state/with-scroll-change/with-all-displacement.ts +15 -0
- package/src/state/with-scroll-change/with-droppable-displacement.ts +13 -0
- package/src/state/with-scroll-change/with-droppable-scroll.ts +13 -0
- package/src/state/with-scroll-change/with-viewport-displacement.ts +7 -0
- package/src/types/redux-devtools.d.ts +17 -0
- package/src/types.ts +495 -0
- package/src/view/animate-in-out/animate-in-out.tsx +98 -0
- package/src/view/animate-in-out/index.ts +2 -0
- package/src/view/check-is-valid-inner-ref.ts +15 -0
- package/src/view/context/app-context.ts +19 -0
- package/src/view/context/droppable-context.ts +12 -0
- package/src/view/context/hooks.ts +21 -0
- package/src/view/context/store-context.ts +8 -0
- package/src/view/data-attributes.ts +37 -0
- package/src/view/drag-drop-context/app.tsx +300 -0
- package/src/view/drag-drop-context/check-doctype.ts +39 -0
- package/src/view/drag-drop-context/check-react-version.ts +72 -0
- package/src/view/drag-drop-context/drag-drop-context-types.ts +8 -0
- package/src/view/drag-drop-context/drag-drop-context.tsx +60 -0
- package/src/view/drag-drop-context/error-boundary.tsx +89 -0
- package/src/view/drag-drop-context/index.ts +2 -0
- package/src/view/drag-drop-context/use-startup-validation.ts +13 -0
- package/src/view/drag-drop-context/use-unique-context-id.ts +13 -0
- package/src/view/draggable/connected-draggable.tsx +420 -0
- package/src/view/draggable/draggable-api.tsx +48 -0
- package/src/view/draggable/draggable-types.ts +204 -0
- package/src/view/draggable/draggable.tsx +167 -0
- package/src/view/draggable/get-style.ts +109 -0
- package/src/view/draggable/index.ts +2 -0
- package/src/view/draggable/use-validation.ts +70 -0
- package/src/view/droppable/connected-droppable.tsx +597 -0
- package/src/view/droppable/droppable-types.ts +96 -0
- package/src/view/droppable/droppable.tsx +167 -0
- package/src/view/droppable/index.ts +2 -0
- package/src/view/droppable/use-validation.ts +102 -0
- package/src/view/event-bindings/bind-events.ts +39 -0
- package/src/view/event-bindings/event-types.ts +15 -0
- package/src/view/get-body-element.ts +8 -0
- package/src/view/get-border-box-center-position.ts +5 -0
- package/src/view/get-document-element.ts +8 -0
- package/src/view/get-elements/find-drag-handle.ts +38 -0
- package/src/view/get-elements/find-draggable.ts +30 -0
- package/src/view/is-strict-equal.ts +2 -0
- package/src/view/is-type-of-element/is-element.ts +10 -0
- package/src/view/is-type-of-element/is-html-element.ts +10 -0
- package/src/view/is-type-of-element/is-svg-element.ts +22 -0
- package/src/view/key-codes.ts +13 -0
- package/src/view/placeholder/index.ts +2 -0
- package/src/view/placeholder/placeholder-types.ts +16 -0
- package/src/view/placeholder/placeholder.tsx +204 -0
- package/src/view/scroll-listener.ts +74 -0
- package/src/view/throw-if-invalid-inner-ref.ts +15 -0
- package/src/view/use-announcer/index.ts +2 -0
- package/src/view/use-announcer/use-announcer.ts +80 -0
- package/src/view/use-dev-setup-warning.ts +22 -0
- package/src/view/use-dev.ts +9 -0
- package/src/view/use-draggable-publisher/get-dimension.ts +44 -0
- package/src/view/use-draggable-publisher/index.ts +2 -0
- package/src/view/use-draggable-publisher/use-draggable-publisher.ts +87 -0
- package/src/view/use-droppable-publisher/check-for-nested-scroll-container.ts +27 -0
- package/src/view/use-droppable-publisher/get-closest-scrollable.ts +96 -0
- package/src/view/use-droppable-publisher/get-dimension.ts +140 -0
- package/src/view/use-droppable-publisher/get-env.ts +32 -0
- package/src/view/use-droppable-publisher/get-listener-options.ts +12 -0
- package/src/view/use-droppable-publisher/get-scroll.ts +7 -0
- package/src/view/use-droppable-publisher/index.ts +2 -0
- package/src/view/use-droppable-publisher/is-in-fixed-container.ts +21 -0
- package/src/view/use-droppable-publisher/use-droppable-publisher.ts +288 -0
- package/src/view/use-focus-marshal/focus-marshal-types.ts +14 -0
- package/src/view/use-focus-marshal/index.ts +2 -0
- package/src/view/use-focus-marshal/use-focus-marshal.ts +128 -0
- package/src/view/use-hidden-text-element/index.ts +2 -0
- package/src/view/use-hidden-text-element/use-hidden-text-element.ts +62 -0
- package/src/view/use-isomorphic-layout-effect.ts +18 -0
- package/src/view/use-previous-ref.ts +26 -0
- package/src/view/use-required-context.ts +22 -0
- package/src/view/use-sensor-marshal/closest.ts +89 -0
- package/src/view/use-sensor-marshal/find-closest-draggable-id-from-event.ts +50 -0
- package/src/view/use-sensor-marshal/index.ts +5 -0
- package/src/view/use-sensor-marshal/is-event-in-interactive-element.ts +67 -0
- package/src/view/use-sensor-marshal/lock.ts +50 -0
- package/src/view/use-sensor-marshal/sensors/use-keyboard-sensor.ts +243 -0
- package/src/view/use-sensor-marshal/sensors/use-mouse-sensor.ts +391 -0
- package/src/view/use-sensor-marshal/sensors/use-touch-sensor.ts +481 -0
- package/src/view/use-sensor-marshal/sensors/util/prevent-standard-key-events.ts +19 -0
- package/src/view/use-sensor-marshal/sensors/util/supported-page-visibility-event-name.ts +29 -0
- package/src/view/use-sensor-marshal/use-sensor-marshal.ts +504 -0
- package/src/view/use-sensor-marshal/use-validate-sensor-hooks.ts +20 -0
- package/src/view/use-style-marshal/get-styles.ts +173 -0
- package/src/view/use-style-marshal/index.ts +2 -0
- package/src/view/use-style-marshal/style-marshal-types.ts +9 -0
- package/src/view/use-style-marshal/use-style-marshal.ts +126 -0
- package/src/view/use-unique-id.ts +25 -0
- package/src/view/visually-hidden-style.ts +16 -0
- package/src/view/window/get-max-window-scroll.ts +19 -0
- package/src/view/window/get-viewport.ts +49 -0
- package/src/view/window/get-window-from-el.ts +12 -0
- package/src/view/window/get-window-scroll.ts +30 -0
- package/src/view/window/scroll-window.ts +7 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Rect, Spacing } from 'css-box-model';
|
|
3
|
+
import getDistanceThresholds, {
|
|
4
|
+
type DistanceThresholds,
|
|
5
|
+
} from './get-distance-thresholds';
|
|
6
|
+
import type { Axis } from '../../../../../types';
|
|
7
|
+
import getValue from './get-value';
|
|
8
|
+
|
|
9
|
+
type GetOnAxisArgs = {
|
|
10
|
+
container: Rect,
|
|
11
|
+
distanceToEdges: Spacing,
|
|
12
|
+
dragStartTime: number,
|
|
13
|
+
axis: Axis,
|
|
14
|
+
shouldUseTimeDampening: boolean,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default ({
|
|
18
|
+
container,
|
|
19
|
+
distanceToEdges,
|
|
20
|
+
dragStartTime,
|
|
21
|
+
axis,
|
|
22
|
+
shouldUseTimeDampening,
|
|
23
|
+
}: GetOnAxisArgs): number => {
|
|
24
|
+
const thresholds: DistanceThresholds = getDistanceThresholds(container, axis);
|
|
25
|
+
const isCloserToEnd: boolean =
|
|
26
|
+
distanceToEdges[axis.end] < distanceToEdges[axis.start];
|
|
27
|
+
|
|
28
|
+
if (isCloserToEnd) {
|
|
29
|
+
return getValue({
|
|
30
|
+
distanceToEdge: distanceToEdges[axis.end],
|
|
31
|
+
thresholds,
|
|
32
|
+
dragStartTime,
|
|
33
|
+
shouldUseTimeDampening,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
-1 *
|
|
39
|
+
getValue({
|
|
40
|
+
distanceToEdge: distanceToEdges[axis.start],
|
|
41
|
+
thresholds,
|
|
42
|
+
dragStartTime,
|
|
43
|
+
shouldUseTimeDampening,
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position, Rect, Spacing } from 'css-box-model';
|
|
3
|
+
import { apply, isEqual, origin } from '../../../position';
|
|
4
|
+
import getScrollOnAxis from './get-scroll-on-axis';
|
|
5
|
+
import adjustForSizeLimits from './adjust-for-size-limits';
|
|
6
|
+
import { horizontal, vertical } from '../../../axis';
|
|
7
|
+
|
|
8
|
+
// will replace -0 and replace with +0
|
|
9
|
+
const clean = apply((value: number) => (value === 0 ? 0 : value));
|
|
10
|
+
|
|
11
|
+
type Args = {
|
|
12
|
+
dragStartTime: number,
|
|
13
|
+
container: Rect,
|
|
14
|
+
subject: Rect,
|
|
15
|
+
center: Position,
|
|
16
|
+
shouldUseTimeDampening: boolean,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default ({
|
|
20
|
+
dragStartTime,
|
|
21
|
+
container,
|
|
22
|
+
subject,
|
|
23
|
+
center,
|
|
24
|
+
shouldUseTimeDampening,
|
|
25
|
+
}: Args): Position | null => {
|
|
26
|
+
// get distance to each edge
|
|
27
|
+
const distanceToEdges: Spacing = {
|
|
28
|
+
top: center.y - container.top,
|
|
29
|
+
right: container.right - center.x,
|
|
30
|
+
bottom: container.bottom - center.y,
|
|
31
|
+
left: center.x - container.left,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// 1. Figure out which x,y values are the best target
|
|
35
|
+
// 2. Can the container scroll in that direction at all?
|
|
36
|
+
// If no for both directions, then return null
|
|
37
|
+
// 3. Is the center close enough to a edge to start a drag?
|
|
38
|
+
// 4. Based on the distance, calculate the speed at which a scroll should occur
|
|
39
|
+
// The lower distance value the faster the scroll should be.
|
|
40
|
+
// Maximum speed value should be hit before the distance is 0
|
|
41
|
+
// Negative values to not continue to increase the speed
|
|
42
|
+
const y: number = getScrollOnAxis({
|
|
43
|
+
container,
|
|
44
|
+
distanceToEdges,
|
|
45
|
+
dragStartTime,
|
|
46
|
+
axis: vertical,
|
|
47
|
+
shouldUseTimeDampening,
|
|
48
|
+
});
|
|
49
|
+
const x: number = getScrollOnAxis({
|
|
50
|
+
container,
|
|
51
|
+
distanceToEdges,
|
|
52
|
+
dragStartTime,
|
|
53
|
+
axis: horizontal,
|
|
54
|
+
shouldUseTimeDampening,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const required: Position = clean({ x, y });
|
|
58
|
+
|
|
59
|
+
// nothing required
|
|
60
|
+
if (isEqual(required, origin)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// need to not scroll in a direction that we are too big to scroll in
|
|
65
|
+
const limited: Position | null | undefined = adjustForSizeLimits({
|
|
66
|
+
container,
|
|
67
|
+
subject,
|
|
68
|
+
proposedScroll: required,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (!limited) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return isEqual(limited, origin) ? null : limited;
|
|
76
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position, Rect } from 'css-box-model';
|
|
3
|
+
import type { Viewport } from '../../../types';
|
|
4
|
+
import getScroll from './get-scroll';
|
|
5
|
+
import { canScrollWindow } from '../can-scroll';
|
|
6
|
+
|
|
7
|
+
type Args = {
|
|
8
|
+
viewport: Viewport,
|
|
9
|
+
subject: Rect,
|
|
10
|
+
center: Position,
|
|
11
|
+
dragStartTime: number,
|
|
12
|
+
shouldUseTimeDampening: boolean,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default ({
|
|
16
|
+
viewport,
|
|
17
|
+
subject,
|
|
18
|
+
center,
|
|
19
|
+
dragStartTime,
|
|
20
|
+
shouldUseTimeDampening,
|
|
21
|
+
}: Args): Position | null => {
|
|
22
|
+
const scroll: Position | null = getScroll({
|
|
23
|
+
dragStartTime,
|
|
24
|
+
container: viewport.frame,
|
|
25
|
+
subject,
|
|
26
|
+
center,
|
|
27
|
+
shouldUseTimeDampening,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return scroll && canScrollWindow(viewport, scroll) ? scroll : null;
|
|
31
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import rafSchd from 'raf-schd';
|
|
3
|
+
import { type Position } from 'css-box-model';
|
|
4
|
+
import type { DraggingState, DroppableId } from '../../../types';
|
|
5
|
+
import scroll from './scroll';
|
|
6
|
+
import { invariant } from '../../../invariant';
|
|
7
|
+
import * as timings from '../../../debug/timings';
|
|
8
|
+
|
|
9
|
+
export type PublicArgs = {
|
|
10
|
+
scrollWindow: (change: Position) => void,
|
|
11
|
+
scrollDroppable: (id: DroppableId, change: Position) => void,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type FluidScroller = {
|
|
15
|
+
scroll: (state: DraggingState) => void,
|
|
16
|
+
start: (state: DraggingState) => void,
|
|
17
|
+
stop: () => void,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type WhileDragging = {
|
|
21
|
+
dragStartTime: number,
|
|
22
|
+
shouldUseTimeDampening: boolean,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default ({
|
|
26
|
+
scrollWindow,
|
|
27
|
+
scrollDroppable,
|
|
28
|
+
}: PublicArgs): FluidScroller => {
|
|
29
|
+
const scheduleWindowScroll = rafSchd(scrollWindow);
|
|
30
|
+
const scheduleDroppableScroll = rafSchd(scrollDroppable);
|
|
31
|
+
let dragging: WhileDragging | null = null;
|
|
32
|
+
|
|
33
|
+
const tryScroll = (state: DraggingState): void => {
|
|
34
|
+
invariant(dragging, 'Cannot fluid scroll if not dragging');
|
|
35
|
+
|
|
36
|
+
const { shouldUseTimeDampening, dragStartTime } = dragging!; // not null
|
|
37
|
+
|
|
38
|
+
scroll({
|
|
39
|
+
state,
|
|
40
|
+
scrollWindow: scheduleWindowScroll,
|
|
41
|
+
scrollDroppable: scheduleDroppableScroll,
|
|
42
|
+
dragStartTime,
|
|
43
|
+
shouldUseTimeDampening,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const start = (state: DraggingState) => {
|
|
48
|
+
timings.start('starting fluid scroller');
|
|
49
|
+
invariant(!dragging, 'Cannot start auto scrolling when already started');
|
|
50
|
+
const dragStartTime: number = Date.now();
|
|
51
|
+
|
|
52
|
+
let wasScrollNeeded: boolean = false;
|
|
53
|
+
const fakeScrollCallback = () => {
|
|
54
|
+
wasScrollNeeded = true;
|
|
55
|
+
};
|
|
56
|
+
scroll({
|
|
57
|
+
state,
|
|
58
|
+
dragStartTime: 0,
|
|
59
|
+
shouldUseTimeDampening: false,
|
|
60
|
+
scrollWindow: fakeScrollCallback,
|
|
61
|
+
scrollDroppable: fakeScrollCallback,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
dragging = {
|
|
65
|
+
dragStartTime,
|
|
66
|
+
shouldUseTimeDampening: wasScrollNeeded,
|
|
67
|
+
};
|
|
68
|
+
timings.finish('starting fluid scroller');
|
|
69
|
+
|
|
70
|
+
// we know an auto scroll is needed - let's do it!
|
|
71
|
+
if (wasScrollNeeded) {
|
|
72
|
+
tryScroll(state);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const stop = () => {
|
|
77
|
+
// can be called defensively
|
|
78
|
+
if (!dragging) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
scheduleWindowScroll.cancel();
|
|
82
|
+
scheduleDroppableScroll.cancel();
|
|
83
|
+
dragging = null;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
start,
|
|
88
|
+
stop,
|
|
89
|
+
scroll: tryScroll,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Position, type Rect } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
DraggingState,
|
|
5
|
+
DroppableId,
|
|
6
|
+
DraggableDimension,
|
|
7
|
+
DroppableDimension,
|
|
8
|
+
Viewport,
|
|
9
|
+
} from '../../../types';
|
|
10
|
+
import getBestScrollableDroppable from './get-best-scrollable-droppable';
|
|
11
|
+
import whatIsDraggedOver from '../../droppable/what-is-dragged-over';
|
|
12
|
+
import getWindowScrollChange from './get-window-scroll-change';
|
|
13
|
+
import getDroppableScrollChange from './get-droppable-scroll-change';
|
|
14
|
+
|
|
15
|
+
type Args = {
|
|
16
|
+
state: DraggingState,
|
|
17
|
+
dragStartTime: number,
|
|
18
|
+
shouldUseTimeDampening: boolean,
|
|
19
|
+
scrollWindow: (scroll: Position) => void,
|
|
20
|
+
scrollDroppable: (id: DroppableId, scroll: Position) => void,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default ({
|
|
24
|
+
state,
|
|
25
|
+
dragStartTime,
|
|
26
|
+
shouldUseTimeDampening,
|
|
27
|
+
scrollWindow,
|
|
28
|
+
scrollDroppable,
|
|
29
|
+
}: Args): void => {
|
|
30
|
+
const center: Position = state.current.page.borderBoxCenter;
|
|
31
|
+
const draggable: DraggableDimension =
|
|
32
|
+
state.dimensions.draggables[state.critical.draggable.id];
|
|
33
|
+
const subject: Rect = draggable.page.marginBox;
|
|
34
|
+
// 1. Can we scroll the viewport?
|
|
35
|
+
if (state.isWindowScrollAllowed) {
|
|
36
|
+
const viewport: Viewport = state.viewport;
|
|
37
|
+
const change: Position | null = getWindowScrollChange({
|
|
38
|
+
dragStartTime,
|
|
39
|
+
viewport,
|
|
40
|
+
subject,
|
|
41
|
+
center,
|
|
42
|
+
shouldUseTimeDampening,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (change) {
|
|
46
|
+
scrollWindow(change);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const droppable: DroppableDimension | null | undefined = getBestScrollableDroppable({
|
|
52
|
+
center,
|
|
53
|
+
destination: whatIsDraggedOver(state.impact),
|
|
54
|
+
droppables: state.dimensions.droppables,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (!droppable) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const change: Position | null = getDroppableScrollChange({
|
|
62
|
+
dragStartTime,
|
|
63
|
+
droppable,
|
|
64
|
+
subject,
|
|
65
|
+
center,
|
|
66
|
+
shouldUseTimeDampening,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (change) {
|
|
70
|
+
scrollDroppable(droppable.descriptor.id, change);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Position } from 'css-box-model';
|
|
3
|
+
import createFluidScroller, { type FluidScroller } from './fluid-scroller';
|
|
4
|
+
import createJumpScroller, { type JumpScroller } from './jump-scroller';
|
|
5
|
+
import type { AutoScroller } from './auto-scroller-types';
|
|
6
|
+
import type { DroppableId, State } from '../../types';
|
|
7
|
+
import type { MoveArgs } from '../action-creators';
|
|
8
|
+
|
|
9
|
+
export type Args = {
|
|
10
|
+
scrollWindow: (offset: Position) => void,
|
|
11
|
+
scrollDroppable: (id: DroppableId, change: Position) => void,
|
|
12
|
+
move: (args: MoveArgs) => unknown,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default ({
|
|
16
|
+
scrollDroppable,
|
|
17
|
+
scrollWindow,
|
|
18
|
+
move,
|
|
19
|
+
}: Args): AutoScroller => {
|
|
20
|
+
const fluidScroller: FluidScroller = createFluidScroller({
|
|
21
|
+
scrollWindow,
|
|
22
|
+
scrollDroppable,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const jumpScroll: JumpScroller = createJumpScroller({
|
|
26
|
+
move,
|
|
27
|
+
scrollWindow,
|
|
28
|
+
scrollDroppable,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const scroll = (state: State) => {
|
|
32
|
+
// Only allowing auto scrolling in the DRAGGING phase
|
|
33
|
+
if (state.phase !== 'DRAGGING') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (state.movementMode === 'FLUID') {
|
|
38
|
+
fluidScroller.scroll(state);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!state.scrollJumpRequest) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
jumpScroll(state);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const scroller: AutoScroller = {
|
|
50
|
+
scroll,
|
|
51
|
+
start: fluidScroller.start,
|
|
52
|
+
stop: fluidScroller.stop,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return scroller;
|
|
56
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Position } from 'css-box-model';
|
|
3
|
+
import { invariant } from '../../invariant';
|
|
4
|
+
import { add, subtract } from '../position';
|
|
5
|
+
import {
|
|
6
|
+
canScrollWindow,
|
|
7
|
+
canScrollDroppable,
|
|
8
|
+
getWindowOverlap,
|
|
9
|
+
getDroppableOverlap,
|
|
10
|
+
} from './can-scroll';
|
|
11
|
+
import whatIsDraggedOver from '../droppable/what-is-dragged-over';
|
|
12
|
+
import { type MoveArgs } from '../action-creators';
|
|
13
|
+
import type {
|
|
14
|
+
DroppableDimension,
|
|
15
|
+
Viewport,
|
|
16
|
+
DraggingState,
|
|
17
|
+
DroppableId,
|
|
18
|
+
} from '../../types';
|
|
19
|
+
|
|
20
|
+
type Args = {
|
|
21
|
+
scrollDroppable: (id: DroppableId, change: Position) => void,
|
|
22
|
+
scrollWindow: (offset: Position) => void,
|
|
23
|
+
move: (args: MoveArgs) => unknown,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type JumpScroller = (state: DraggingState) => void;
|
|
27
|
+
|
|
28
|
+
type Remainder = Position;
|
|
29
|
+
|
|
30
|
+
export default ({
|
|
31
|
+
move,
|
|
32
|
+
scrollDroppable,
|
|
33
|
+
scrollWindow,
|
|
34
|
+
}: Args): JumpScroller => {
|
|
35
|
+
const moveByOffset = (state: DraggingState, offset: Position) => {
|
|
36
|
+
const client: Position = add(state.current.client.selection, offset);
|
|
37
|
+
move({ client });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const scrollDroppableAsMuchAsItCan = (
|
|
41
|
+
droppable: DroppableDimension,
|
|
42
|
+
change: Position,
|
|
43
|
+
): Remainder | null => {
|
|
44
|
+
// Droppable cannot absorb any of the scroll
|
|
45
|
+
if (!canScrollDroppable(droppable, change)) {
|
|
46
|
+
return change;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Position | null
|
|
50
|
+
const overlap: Position | null = getDroppableOverlap(droppable, change);
|
|
51
|
+
|
|
52
|
+
// Droppable can absorb the entire change
|
|
53
|
+
if (!overlap) {
|
|
54
|
+
scrollDroppable(droppable.descriptor.id, change);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Droppable can only absorb a part of the change
|
|
59
|
+
const whatTheDroppableCanScroll: Position = subtract(change, overlap);
|
|
60
|
+
scrollDroppable(droppable.descriptor.id, whatTheDroppableCanScroll);
|
|
61
|
+
|
|
62
|
+
const remainder: Position = subtract(change, whatTheDroppableCanScroll);
|
|
63
|
+
return remainder;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const scrollWindowAsMuchAsItCan = (
|
|
67
|
+
isWindowScrollAllowed: boolean,
|
|
68
|
+
viewport: Viewport,
|
|
69
|
+
change: Position,
|
|
70
|
+
): Position | null => {
|
|
71
|
+
if (!isWindowScrollAllowed) {
|
|
72
|
+
return change;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!canScrollWindow(viewport, change)) {
|
|
76
|
+
// window cannot absorb any of the scroll
|
|
77
|
+
return change;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const overlap: Position | null = getWindowOverlap(viewport, change);
|
|
81
|
+
|
|
82
|
+
// window can absorb entire scroll
|
|
83
|
+
if (!overlap) {
|
|
84
|
+
scrollWindow(change);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// window can only absorb a part of the scroll
|
|
89
|
+
const whatTheWindowCanScroll: Position = subtract(change, overlap);
|
|
90
|
+
scrollWindow(whatTheWindowCanScroll);
|
|
91
|
+
|
|
92
|
+
const remainder: Position = subtract(change, whatTheWindowCanScroll);
|
|
93
|
+
return remainder;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const jumpScroller: JumpScroller = (state: DraggingState) => {
|
|
97
|
+
const request: Position | null = state.scrollJumpRequest;
|
|
98
|
+
|
|
99
|
+
if (!request) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const destination: DroppableId | null = whatIsDraggedOver(state.impact);
|
|
104
|
+
invariant(
|
|
105
|
+
destination,
|
|
106
|
+
'Cannot perform a jump scroll when there is no destination',
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// 1. We scroll the droppable first if we can to avoid the draggable
|
|
110
|
+
// leaving the list
|
|
111
|
+
|
|
112
|
+
const droppableRemainder: Position | null = scrollDroppableAsMuchAsItCan(
|
|
113
|
+
state.dimensions.droppables[destination],
|
|
114
|
+
request,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// droppable absorbed the entire scroll
|
|
118
|
+
if (!droppableRemainder) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const viewport: Viewport = state.viewport;
|
|
123
|
+
const windowRemainder: Position | null = scrollWindowAsMuchAsItCan(
|
|
124
|
+
state.isWindowScrollAllowed,
|
|
125
|
+
viewport,
|
|
126
|
+
droppableRemainder,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// window could absorb all the droppable remainder
|
|
130
|
+
if (!windowRemainder) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// The entire scroll could not be absorbed by the droppable and window
|
|
135
|
+
// so we manually move whatever is left
|
|
136
|
+
moveByOffset(state, windowRemainder);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return jumpScroller;
|
|
140
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { HorizontalAxis, VerticalAxis } from '../types';
|
|
3
|
+
|
|
4
|
+
export const vertical: VerticalAxis = {
|
|
5
|
+
direction: 'vertical',
|
|
6
|
+
line: 'y',
|
|
7
|
+
crossAxisLine: 'x',
|
|
8
|
+
start: 'top',
|
|
9
|
+
end: 'bottom',
|
|
10
|
+
size: 'height',
|
|
11
|
+
crossAxisStart: 'left',
|
|
12
|
+
crossAxisEnd: 'right',
|
|
13
|
+
crossAxisSize: 'width',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const horizontal: HorizontalAxis = {
|
|
17
|
+
direction: 'horizontal',
|
|
18
|
+
line: 'x',
|
|
19
|
+
crossAxisLine: 'y',
|
|
20
|
+
start: 'left',
|
|
21
|
+
end: 'right',
|
|
22
|
+
size: 'width',
|
|
23
|
+
crossAxisStart: 'top',
|
|
24
|
+
crossAxisEnd: 'bottom',
|
|
25
|
+
crossAxisSize: 'height',
|
|
26
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type {
|
|
3
|
+
DraggableDimension,
|
|
4
|
+
DroppableDimension,
|
|
5
|
+
DragImpact,
|
|
6
|
+
DisplacementGroups,
|
|
7
|
+
Viewport,
|
|
8
|
+
DisplacedBy,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import removeDraggableFromList from '../remove-draggable-from-list';
|
|
11
|
+
import isHomeOf from '../droppable/is-home-of';
|
|
12
|
+
import { emptyGroups } from '../no-impact';
|
|
13
|
+
import { find } from '../../native-with-fallback';
|
|
14
|
+
import getDisplacementGroups from '../get-displacement-groups';
|
|
15
|
+
|
|
16
|
+
// Exact
|
|
17
|
+
type Args = {
|
|
18
|
+
draggable: DraggableDimension,
|
|
19
|
+
insideDestination: DraggableDimension[],
|
|
20
|
+
destination: DroppableDimension,
|
|
21
|
+
viewport: Viewport,
|
|
22
|
+
displacedBy: DisplacedBy,
|
|
23
|
+
last: DisplacementGroups,
|
|
24
|
+
index: number | null,
|
|
25
|
+
forceShouldAnimate?: boolean,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function getIndexOfLastItem(
|
|
29
|
+
draggables: DraggableDimension[],
|
|
30
|
+
options: { inHomeList: boolean }, // Exact
|
|
31
|
+
): number {
|
|
32
|
+
if (!draggables.length) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const indexOfLastItem: number =
|
|
37
|
+
draggables[draggables.length - 1].descriptor.index;
|
|
38
|
+
|
|
39
|
+
// When in a foreign list there will be an additional one item in the list
|
|
40
|
+
return options.inHomeList ? indexOfLastItem : indexOfLastItem + 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Exact
|
|
44
|
+
type GoAtEndArgs = {
|
|
45
|
+
insideDestination: DraggableDimension[],
|
|
46
|
+
inHomeList: boolean,
|
|
47
|
+
displacedBy: DisplacedBy,
|
|
48
|
+
destination: DroppableDimension,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function goAtEnd({
|
|
52
|
+
insideDestination,
|
|
53
|
+
inHomeList,
|
|
54
|
+
displacedBy,
|
|
55
|
+
destination,
|
|
56
|
+
}: GoAtEndArgs): DragImpact {
|
|
57
|
+
const newIndex: number = getIndexOfLastItem(insideDestination, {
|
|
58
|
+
inHomeList,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
displaced: emptyGroups,
|
|
63
|
+
displacedBy,
|
|
64
|
+
at: {
|
|
65
|
+
type: 'REORDER',
|
|
66
|
+
destination: {
|
|
67
|
+
droppableId: destination.descriptor.id,
|
|
68
|
+
index: newIndex,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default function calculateReorderImpact({
|
|
75
|
+
draggable,
|
|
76
|
+
insideDestination,
|
|
77
|
+
destination,
|
|
78
|
+
viewport,
|
|
79
|
+
displacedBy,
|
|
80
|
+
last,
|
|
81
|
+
index,
|
|
82
|
+
forceShouldAnimate,
|
|
83
|
+
}: Args): DragImpact {
|
|
84
|
+
const inHomeList: boolean = isHomeOf(draggable, destination);
|
|
85
|
+
|
|
86
|
+
// Go into last spot of list
|
|
87
|
+
if (index == null) {
|
|
88
|
+
return goAtEnd({
|
|
89
|
+
insideDestination,
|
|
90
|
+
inHomeList,
|
|
91
|
+
displacedBy,
|
|
92
|
+
destination,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// this might be the dragging item
|
|
97
|
+
const match: DraggableDimension | null | undefined = find(
|
|
98
|
+
insideDestination,
|
|
99
|
+
(item: DraggableDimension) => item.descriptor.index === index,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (!match) {
|
|
103
|
+
return goAtEnd({
|
|
104
|
+
insideDestination,
|
|
105
|
+
inHomeList,
|
|
106
|
+
displacedBy,
|
|
107
|
+
destination,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const withoutDragging: DraggableDimension[] = removeDraggableFromList(
|
|
111
|
+
draggable,
|
|
112
|
+
insideDestination,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const sliceFrom: number = insideDestination.indexOf(match);
|
|
116
|
+
const impacted: DraggableDimension[] = withoutDragging.slice(sliceFrom);
|
|
117
|
+
|
|
118
|
+
const displaced: DisplacementGroups = getDisplacementGroups({
|
|
119
|
+
afterDragging: impacted,
|
|
120
|
+
destination,
|
|
121
|
+
displacedBy,
|
|
122
|
+
last,
|
|
123
|
+
viewport: viewport.frame,
|
|
124
|
+
forceShouldAnimate,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
displaced,
|
|
129
|
+
displacedBy,
|
|
130
|
+
at: {
|
|
131
|
+
type: 'REORDER',
|
|
132
|
+
destination: {
|
|
133
|
+
droppableId: destination.descriptor.id,
|
|
134
|
+
index,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|