@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,113 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { offset, type Position, type BoxModel } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
Axis,
|
|
5
|
+
DragImpact,
|
|
6
|
+
DraggableId,
|
|
7
|
+
DraggableDimension,
|
|
8
|
+
DraggableDimensionMap,
|
|
9
|
+
DroppableDimension,
|
|
10
|
+
LiftEffect,
|
|
11
|
+
} from '../../../types';
|
|
12
|
+
import { goBefore, goAfter, goIntoStart } from '../move-relative-to';
|
|
13
|
+
import getDraggablesInsideDroppable from '../../get-draggables-inside-droppable';
|
|
14
|
+
import { negate } from '../../position';
|
|
15
|
+
import didStartAfterCritical from '../../did-start-after-critical';
|
|
16
|
+
|
|
17
|
+
// Exact
|
|
18
|
+
type NewHomeArgs = {
|
|
19
|
+
impact: DragImpact,
|
|
20
|
+
draggable: DraggableDimension,
|
|
21
|
+
draggables: DraggableDimensionMap,
|
|
22
|
+
droppable: DroppableDimension,
|
|
23
|
+
afterCritical: LiftEffect,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Returns the client offset required to move an item from its
|
|
27
|
+
// original client position to its final resting position
|
|
28
|
+
export default ({
|
|
29
|
+
impact,
|
|
30
|
+
draggable,
|
|
31
|
+
draggables,
|
|
32
|
+
droppable,
|
|
33
|
+
afterCritical,
|
|
34
|
+
}: NewHomeArgs): Position => {
|
|
35
|
+
const insideDestination: DraggableDimension[] = getDraggablesInsideDroppable(
|
|
36
|
+
droppable.descriptor.id,
|
|
37
|
+
draggables,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const draggablePage: BoxModel = draggable.page;
|
|
41
|
+
const axis: Axis = droppable.axis;
|
|
42
|
+
|
|
43
|
+
// this will only happen in a foreign list
|
|
44
|
+
if (!insideDestination.length) {
|
|
45
|
+
return goIntoStart({
|
|
46
|
+
axis,
|
|
47
|
+
moveInto: droppable.page,
|
|
48
|
+
isMoving: draggablePage,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { displaced, displacedBy } = impact;
|
|
53
|
+
const closestAfter: DraggableId | null = displaced.all[0];
|
|
54
|
+
|
|
55
|
+
// go before the first displaced item
|
|
56
|
+
// items can only be displaced forwards
|
|
57
|
+
if (closestAfter) {
|
|
58
|
+
const closest: DraggableDimension = draggables[closestAfter];
|
|
59
|
+
// want to go before where it would be with the displacement
|
|
60
|
+
|
|
61
|
+
// target is displaced and is already in it's starting position
|
|
62
|
+
if (didStartAfterCritical(closestAfter, afterCritical)) {
|
|
63
|
+
return goBefore({
|
|
64
|
+
axis,
|
|
65
|
+
moveRelativeTo: closest.page,
|
|
66
|
+
isMoving: draggablePage,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// target has been displaced during the drag and it is not in its starting position
|
|
71
|
+
// we need to account for the displacement
|
|
72
|
+
const withDisplacement: BoxModel = offset(closest.page, displacedBy.point);
|
|
73
|
+
|
|
74
|
+
return goBefore({
|
|
75
|
+
axis,
|
|
76
|
+
moveRelativeTo: withDisplacement,
|
|
77
|
+
isMoving: draggablePage,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Nothing in list is displaced, we should go after the last item
|
|
82
|
+
|
|
83
|
+
const last: DraggableDimension =
|
|
84
|
+
insideDestination[insideDestination.length - 1];
|
|
85
|
+
|
|
86
|
+
// we can just go into our original position if the last item
|
|
87
|
+
// is the dragging item
|
|
88
|
+
if (last.descriptor.id === draggable.descriptor.id) {
|
|
89
|
+
return draggablePage.borderBox.center;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (didStartAfterCritical(last.descriptor.id, afterCritical)) {
|
|
93
|
+
// if the item started displaced and it is no longer displaced then
|
|
94
|
+
// we need to go after it it's non-displaced position
|
|
95
|
+
|
|
96
|
+
const page: BoxModel = offset(
|
|
97
|
+
last.page,
|
|
98
|
+
negate(afterCritical.displacedBy.point),
|
|
99
|
+
);
|
|
100
|
+
return goAfter({
|
|
101
|
+
axis,
|
|
102
|
+
moveRelativeTo: page,
|
|
103
|
+
isMoving: draggablePage,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// item is in its resting spot. we can go straight after it
|
|
108
|
+
return goAfter({
|
|
109
|
+
axis,
|
|
110
|
+
moveRelativeTo: last.page,
|
|
111
|
+
isMoving: draggablePage,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position, BoxModel, Rect } from 'css-box-model';
|
|
3
|
+
import { patch } from '../position';
|
|
4
|
+
import type { Axis } from '../../types';
|
|
5
|
+
|
|
6
|
+
type Args = {
|
|
7
|
+
axis: Axis,
|
|
8
|
+
moveRelativeTo: BoxModel,
|
|
9
|
+
isMoving: BoxModel,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const distanceFromStartToBorderBoxCenter = (
|
|
13
|
+
axis: Axis,
|
|
14
|
+
box: BoxModel,
|
|
15
|
+
): number => box.margin[axis.start] + box.borderBox[axis.size] / 2;
|
|
16
|
+
|
|
17
|
+
const distanceFromEndToBorderBoxCenter = (axis: Axis, box: BoxModel): number =>
|
|
18
|
+
box.margin[axis.end] + box.borderBox[axis.size] / 2;
|
|
19
|
+
|
|
20
|
+
// We align the moving item against the cross axis start of the target
|
|
21
|
+
// We used to align the moving item cross axis center with the cross axis center of the target.
|
|
22
|
+
// However, this leads to a bad experience when reordering columns
|
|
23
|
+
const getCrossAxisBorderBoxCenter = (
|
|
24
|
+
axis: Axis,
|
|
25
|
+
target: Rect,
|
|
26
|
+
isMoving: BoxModel,
|
|
27
|
+
): number =>
|
|
28
|
+
target[axis.crossAxisStart] +
|
|
29
|
+
isMoving.margin[axis.crossAxisStart] +
|
|
30
|
+
isMoving.borderBox[axis.crossAxisSize] / 2;
|
|
31
|
+
|
|
32
|
+
export const goAfter = ({ axis, moveRelativeTo, isMoving }: Args): Position =>
|
|
33
|
+
patch(
|
|
34
|
+
axis.line,
|
|
35
|
+
// start measuring from the end of the target
|
|
36
|
+
moveRelativeTo.marginBox[axis.end] +
|
|
37
|
+
distanceFromStartToBorderBoxCenter(axis, isMoving),
|
|
38
|
+
getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const goBefore = ({ axis, moveRelativeTo, isMoving }: Args): Position =>
|
|
42
|
+
patch(
|
|
43
|
+
axis.line,
|
|
44
|
+
// start measuring from the start of the target
|
|
45
|
+
moveRelativeTo.marginBox[axis.start] -
|
|
46
|
+
distanceFromEndToBorderBoxCenter(axis, isMoving),
|
|
47
|
+
getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Exact
|
|
51
|
+
type GoIntoArgs = {
|
|
52
|
+
axis: Axis,
|
|
53
|
+
moveInto: BoxModel,
|
|
54
|
+
isMoving: BoxModel,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// moves into the content box
|
|
58
|
+
export const goIntoStart = ({
|
|
59
|
+
axis,
|
|
60
|
+
moveInto,
|
|
61
|
+
isMoving,
|
|
62
|
+
}: GoIntoArgs): Position =>
|
|
63
|
+
patch(
|
|
64
|
+
axis.line,
|
|
65
|
+
moveInto.contentBox[axis.start] +
|
|
66
|
+
distanceFromStartToBorderBoxCenter(axis, isMoving),
|
|
67
|
+
getCrossAxisBorderBoxCenter(axis, moveInto.contentBox, isMoving),
|
|
68
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Position } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
DisplacementGroups,
|
|
5
|
+
LiftEffect,
|
|
6
|
+
DraggableId,
|
|
7
|
+
DisplacedBy,
|
|
8
|
+
} from '../types';
|
|
9
|
+
import { origin, negate } from './position';
|
|
10
|
+
import didStartAfterCritical from './did-start-after-critical';
|
|
11
|
+
|
|
12
|
+
// Exact
|
|
13
|
+
type Args = {
|
|
14
|
+
displaced: DisplacementGroups,
|
|
15
|
+
afterCritical: LiftEffect,
|
|
16
|
+
combineWith: DraggableId,
|
|
17
|
+
displacedBy: DisplacedBy,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default ({
|
|
21
|
+
displaced,
|
|
22
|
+
afterCritical,
|
|
23
|
+
combineWith,
|
|
24
|
+
displacedBy,
|
|
25
|
+
}: Args): Position => {
|
|
26
|
+
const isDisplaced: boolean = Boolean(
|
|
27
|
+
displaced.visible[combineWith] || displaced.invisible[combineWith],
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (didStartAfterCritical(combineWith, afterCritical)) {
|
|
31
|
+
return isDisplaced ? origin : negate(displacedBy.point);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return isDisplaced ? displacedBy.point : origin;
|
|
35
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import memoizeOne from 'memoize-one';
|
|
3
|
+
import { type Position } from 'css-box-model';
|
|
4
|
+
import type { Axis, DisplacedBy } from '../types';
|
|
5
|
+
import { patch } from './position';
|
|
6
|
+
|
|
7
|
+
// TODO: memoization needed?
|
|
8
|
+
export default memoizeOne(function getDisplacedBy(
|
|
9
|
+
axis: Axis,
|
|
10
|
+
displaceBy: Position,
|
|
11
|
+
): DisplacedBy {
|
|
12
|
+
const displacement: number = displaceBy[axis.line];
|
|
13
|
+
return {
|
|
14
|
+
value: displacement,
|
|
15
|
+
point: patch(axis.line, displacement),
|
|
16
|
+
};
|
|
17
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Rect, type Spacing, expand, getRect } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
DraggableId,
|
|
5
|
+
Displacement,
|
|
6
|
+
DraggableDimension,
|
|
7
|
+
DroppableDimension,
|
|
8
|
+
DisplacementGroups,
|
|
9
|
+
DisplacedBy,
|
|
10
|
+
} from '../types';
|
|
11
|
+
import { isPartiallyVisible } from './visibility/is-visible';
|
|
12
|
+
|
|
13
|
+
// Exact
|
|
14
|
+
type Args = {
|
|
15
|
+
afterDragging: DraggableDimension[],
|
|
16
|
+
destination: DroppableDimension,
|
|
17
|
+
displacedBy: DisplacedBy,
|
|
18
|
+
last: DisplacementGroups | null,
|
|
19
|
+
viewport: Rect,
|
|
20
|
+
forceShouldAnimate?: boolean,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getShouldAnimate = (
|
|
24
|
+
id: any,
|
|
25
|
+
last: DisplacementGroups | null,
|
|
26
|
+
forceShouldAnimate?: boolean,
|
|
27
|
+
) => {
|
|
28
|
+
// Use a forced value if provided
|
|
29
|
+
if (typeof forceShouldAnimate === 'boolean') {
|
|
30
|
+
return forceShouldAnimate;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// nothing to gauge animation from
|
|
34
|
+
if (!last) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { invisible, visible } = last;
|
|
39
|
+
|
|
40
|
+
// it was previously invisible - no animation
|
|
41
|
+
if (invisible[id]) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const previous: Displacement | null = visible[id];
|
|
46
|
+
|
|
47
|
+
return previous ? previous.shouldAnimate : true;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Note: it is also an optimisation to not render the displacement on
|
|
51
|
+
// items when they are not longer visible.
|
|
52
|
+
// This prevents a lot of .render() calls when leaving / entering a list
|
|
53
|
+
|
|
54
|
+
function getTarget(
|
|
55
|
+
draggable: DraggableDimension,
|
|
56
|
+
displacedBy: DisplacedBy,
|
|
57
|
+
): Rect {
|
|
58
|
+
const marginBox: Rect = draggable.page.marginBox;
|
|
59
|
+
|
|
60
|
+
// ## Visibility overscanning
|
|
61
|
+
// We are expanding rather than offsetting the marginBox.
|
|
62
|
+
// In some cases we want
|
|
63
|
+
// - the target based on the starting position (such as when dropping outside of any list)
|
|
64
|
+
// - the target based on the items position without starting displacement (such as when moving inside a list)
|
|
65
|
+
// To keep things simple we just expand the whole area for this check
|
|
66
|
+
// The worst case is some minor redundant offscreen movements
|
|
67
|
+
const expandBy: Spacing = {
|
|
68
|
+
// pull backwards into viewport
|
|
69
|
+
top: displacedBy.point.y,
|
|
70
|
+
right: 0,
|
|
71
|
+
bottom: 0,
|
|
72
|
+
// pull backwards into viewport
|
|
73
|
+
left: displacedBy.point.x,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return getRect(expand(marginBox, expandBy));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default function getDisplacementGroups({
|
|
80
|
+
afterDragging,
|
|
81
|
+
destination,
|
|
82
|
+
displacedBy,
|
|
83
|
+
viewport,
|
|
84
|
+
forceShouldAnimate,
|
|
85
|
+
last,
|
|
86
|
+
}: Args): DisplacementGroups {
|
|
87
|
+
return afterDragging.reduce(
|
|
88
|
+
function process(
|
|
89
|
+
groups: DisplacementGroups,
|
|
90
|
+
draggable: DraggableDimension,
|
|
91
|
+
): DisplacementGroups {
|
|
92
|
+
const target: Rect = getTarget(draggable, displacedBy);
|
|
93
|
+
const id: DraggableId = draggable.descriptor.id;
|
|
94
|
+
|
|
95
|
+
groups.all.push(id);
|
|
96
|
+
|
|
97
|
+
const isVisible: boolean = isPartiallyVisible({
|
|
98
|
+
target,
|
|
99
|
+
destination,
|
|
100
|
+
viewport,
|
|
101
|
+
withDroppableDisplacement: true,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (!isVisible) {
|
|
105
|
+
groups.invisible[draggable.descriptor.id] = true;
|
|
106
|
+
return groups;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// item is visible
|
|
110
|
+
|
|
111
|
+
const shouldAnimate: boolean = getShouldAnimate(
|
|
112
|
+
id,
|
|
113
|
+
last,
|
|
114
|
+
forceShouldAnimate,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const displacement: Displacement = {
|
|
118
|
+
draggableId: id,
|
|
119
|
+
shouldAnimate,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
groups.visible[id] = displacement;
|
|
123
|
+
return groups;
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
all: [],
|
|
127
|
+
visible: {},
|
|
128
|
+
invisible: {},
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type { Rect } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
DraggableId,
|
|
5
|
+
Axis,
|
|
6
|
+
DraggableDimension,
|
|
7
|
+
DroppableDimension,
|
|
8
|
+
DragImpact,
|
|
9
|
+
LiftEffect,
|
|
10
|
+
DisplacedBy,
|
|
11
|
+
} from '../../types';
|
|
12
|
+
import { find } from '../../native-with-fallback';
|
|
13
|
+
import getDidStartAfterCritical from '../did-start-after-critical';
|
|
14
|
+
import getDisplacedBy from '../get-displaced-by';
|
|
15
|
+
import getIsDisplaced from '../get-is-displaced';
|
|
16
|
+
import removeDraggableFromList from '../remove-draggable-from-list';
|
|
17
|
+
|
|
18
|
+
// Exact
|
|
19
|
+
type Args = {
|
|
20
|
+
draggable: DraggableDimension,
|
|
21
|
+
pageBorderBoxWithDroppableScroll: Rect,
|
|
22
|
+
previousImpact: DragImpact,
|
|
23
|
+
destination: DroppableDimension,
|
|
24
|
+
insideDestination: DraggableDimension[],
|
|
25
|
+
afterCritical: LiftEffect,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// exported for testing
|
|
29
|
+
export const combineThresholdDivisor: number = 4;
|
|
30
|
+
|
|
31
|
+
export default ({
|
|
32
|
+
draggable,
|
|
33
|
+
pageBorderBoxWithDroppableScroll: targetRect,
|
|
34
|
+
previousImpact,
|
|
35
|
+
destination,
|
|
36
|
+
insideDestination,
|
|
37
|
+
afterCritical,
|
|
38
|
+
}: Args): DragImpact | null => {
|
|
39
|
+
if (!destination.isCombineEnabled) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const axis: Axis = destination.axis;
|
|
43
|
+
const displacedBy: DisplacedBy = getDisplacedBy(
|
|
44
|
+
destination.axis,
|
|
45
|
+
draggable.displaceBy,
|
|
46
|
+
);
|
|
47
|
+
const displacement: number = displacedBy.value;
|
|
48
|
+
|
|
49
|
+
const targetStart: number = targetRect[axis.start];
|
|
50
|
+
const targetEnd: number = targetRect[axis.end];
|
|
51
|
+
|
|
52
|
+
const withoutDragging: DraggableDimension[] = removeDraggableFromList(
|
|
53
|
+
draggable,
|
|
54
|
+
insideDestination,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const combineWith: DraggableDimension | null | undefined = find(
|
|
58
|
+
withoutDragging,
|
|
59
|
+
(child: DraggableDimension): boolean => {
|
|
60
|
+
const id: DraggableId = child.descriptor.id;
|
|
61
|
+
const childRect: Rect = child.page.borderBox;
|
|
62
|
+
const childSize: number = childRect[axis.size];
|
|
63
|
+
const threshold: number = childSize / combineThresholdDivisor;
|
|
64
|
+
|
|
65
|
+
const didStartAfterCritical: boolean = getDidStartAfterCritical(
|
|
66
|
+
id,
|
|
67
|
+
afterCritical,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const isDisplaced: boolean = getIsDisplaced({
|
|
71
|
+
displaced: previousImpact.displaced,
|
|
72
|
+
id,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
Only combining when in the combine region
|
|
77
|
+
As soon as a boundary is hit then no longer combining
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
if (didStartAfterCritical) {
|
|
81
|
+
// In original position
|
|
82
|
+
// Will combine with item when inside a band
|
|
83
|
+
if (isDisplaced) {
|
|
84
|
+
return (
|
|
85
|
+
targetEnd > childRect[axis.start] + threshold &&
|
|
86
|
+
targetEnd < childRect[axis.end] - threshold
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// child is now 'displaced' backwards from where it started
|
|
91
|
+
// want to combine when we move backwards onto it
|
|
92
|
+
return (
|
|
93
|
+
targetStart > childRect[axis.start] - displacement + threshold &&
|
|
94
|
+
targetStart < childRect[axis.end] - displacement - threshold
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// item has moved forwards
|
|
99
|
+
if (isDisplaced) {
|
|
100
|
+
return (
|
|
101
|
+
targetEnd > childRect[axis.start] + displacement + threshold &&
|
|
102
|
+
targetEnd < childRect[axis.end] + displacement - threshold
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// is in resting position - being moved backwards on to
|
|
107
|
+
return (
|
|
108
|
+
targetStart > childRect[axis.start] + threshold &&
|
|
109
|
+
targetStart < childRect[axis.end] - threshold
|
|
110
|
+
);
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
if (!combineWith) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const impact: DragImpact = {
|
|
119
|
+
// no change to displacement when combining
|
|
120
|
+
displacedBy,
|
|
121
|
+
displaced: previousImpact.displaced,
|
|
122
|
+
at: {
|
|
123
|
+
type: 'COMBINE',
|
|
124
|
+
combine: {
|
|
125
|
+
draggableId: combineWith.descriptor.id,
|
|
126
|
+
droppableId: destination.descriptor.id,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
return impact;
|
|
131
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { type Rect } from 'css-box-model';
|
|
3
|
+
import type {
|
|
4
|
+
DraggableId,
|
|
5
|
+
DraggableDimension,
|
|
6
|
+
DroppableDimension,
|
|
7
|
+
DragImpact,
|
|
8
|
+
Axis,
|
|
9
|
+
DisplacementGroups,
|
|
10
|
+
Viewport,
|
|
11
|
+
DisplacedBy,
|
|
12
|
+
LiftEffect,
|
|
13
|
+
} from '../../types';
|
|
14
|
+
import getDisplacedBy from '../get-displaced-by';
|
|
15
|
+
import removeDraggableFromList from '../remove-draggable-from-list';
|
|
16
|
+
import isHomeOf from '../droppable/is-home-of';
|
|
17
|
+
import { find } from '../../native-with-fallback';
|
|
18
|
+
import getDidStartAfterCritical from '../did-start-after-critical';
|
|
19
|
+
import calculateReorderImpact from '../calculate-drag-impact/calculate-reorder-impact';
|
|
20
|
+
import getIsDisplaced from '../get-is-displaced';
|
|
21
|
+
|
|
22
|
+
// Exact
|
|
23
|
+
type Args = {
|
|
24
|
+
pageBorderBoxWithDroppableScroll: Rect,
|
|
25
|
+
draggable: DraggableDimension,
|
|
26
|
+
destination: DroppableDimension,
|
|
27
|
+
insideDestination: DraggableDimension[],
|
|
28
|
+
last: DisplacementGroups,
|
|
29
|
+
viewport: Viewport,
|
|
30
|
+
afterCritical: LiftEffect,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Exact
|
|
34
|
+
type AtIndexArgs = {
|
|
35
|
+
draggable: DraggableDimension,
|
|
36
|
+
closest?: DraggableDimension | null,
|
|
37
|
+
inHomeList: boolean,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function atIndex({ draggable, closest, inHomeList }: AtIndexArgs): number | null {
|
|
41
|
+
if (!closest) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!inHomeList) {
|
|
46
|
+
return closest.descriptor.index;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (closest.descriptor.index > draggable.descriptor.index) {
|
|
50
|
+
return closest.descriptor.index - 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return closest.descriptor.index;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default ({
|
|
57
|
+
pageBorderBoxWithDroppableScroll: targetRect,
|
|
58
|
+
draggable,
|
|
59
|
+
destination,
|
|
60
|
+
insideDestination,
|
|
61
|
+
last,
|
|
62
|
+
viewport,
|
|
63
|
+
afterCritical,
|
|
64
|
+
}: Args): DragImpact => {
|
|
65
|
+
const axis: Axis = destination.axis;
|
|
66
|
+
const displacedBy: DisplacedBy = getDisplacedBy(
|
|
67
|
+
destination.axis,
|
|
68
|
+
draggable.displaceBy,
|
|
69
|
+
);
|
|
70
|
+
const displacement: number = displacedBy.value;
|
|
71
|
+
|
|
72
|
+
const targetStart: number = targetRect[axis.start];
|
|
73
|
+
const targetEnd: number = targetRect[axis.end];
|
|
74
|
+
|
|
75
|
+
const withoutDragging: DraggableDimension[] = removeDraggableFromList(
|
|
76
|
+
draggable,
|
|
77
|
+
insideDestination,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const closest: DraggableDimension | null | undefined = find(
|
|
81
|
+
withoutDragging,
|
|
82
|
+
(child: DraggableDimension): boolean => {
|
|
83
|
+
const id: DraggableId = child.descriptor.id;
|
|
84
|
+
const childCenter: number = child.page.borderBox.center[axis.line];
|
|
85
|
+
|
|
86
|
+
const didStartAfterCritical: boolean = getDidStartAfterCritical(
|
|
87
|
+
id,
|
|
88
|
+
afterCritical,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const isDisplaced: boolean = getIsDisplaced({ displaced: last, id });
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
Note: we change things when moving *past* the child center - not when it hits the center
|
|
95
|
+
If we make it when we *hit* the child center then there can be
|
|
96
|
+
a hit on the next update causing a flicker.
|
|
97
|
+
|
|
98
|
+
- Update 1: targetBottom hits center => displace backwards
|
|
99
|
+
- Update 2: targetStart is now hitting the displaced center => displace forwards
|
|
100
|
+
- Update 3: goto 1 (boom)
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
if (didStartAfterCritical) {
|
|
104
|
+
// Continue to displace while targetEnd before the childCenter
|
|
105
|
+
// Move once we *move forward past* the childCenter
|
|
106
|
+
if (isDisplaced) {
|
|
107
|
+
return targetEnd <= childCenter;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Has been moved backwards from where it started
|
|
111
|
+
// Displace forwards when targetStart *moves backwards past* the displaced childCenter
|
|
112
|
+
return targetStart < childCenter - displacement;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Item has been shifted forward.
|
|
116
|
+
// Remove displacement when targetEnd moves forward past the displaced center
|
|
117
|
+
if (isDisplaced) {
|
|
118
|
+
return targetEnd <= childCenter + displacement;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Item is behind the dragging item
|
|
122
|
+
// We want to displace it if the targetStart goes *backwards past* the childCenter
|
|
123
|
+
return targetStart < childCenter;
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const newIndex: number | null = atIndex({
|
|
128
|
+
draggable,
|
|
129
|
+
closest,
|
|
130
|
+
inHomeList: isHomeOf(draggable, destination),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// TODO: index cannot be null?
|
|
134
|
+
// otherwise return null from there and return empty impact
|
|
135
|
+
// that was calculate reorder impact does not need to account for a null index
|
|
136
|
+
return calculateReorderImpact({
|
|
137
|
+
draggable,
|
|
138
|
+
insideDestination,
|
|
139
|
+
destination,
|
|
140
|
+
viewport,
|
|
141
|
+
last,
|
|
142
|
+
displacedBy,
|
|
143
|
+
index: newIndex,
|
|
144
|
+
});
|
|
145
|
+
};
|