Fix: ドラッグに関する問題
This commit is contained in:
parent
2fddfbf0c2
commit
b6c12c6d1f
3 changed files with 34 additions and 12 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { useState, useCallback } from 'react';
|
import { useState, useCallback } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
|
||||||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ import {
|
||||||
useSensors,
|
useSensors,
|
||||||
DragOverlay,
|
DragOverlay,
|
||||||
} from '@dnd-kit/core';
|
} from '@dnd-kit/core';
|
||||||
|
import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
|
||||||
import {
|
import {
|
||||||
SortableContext,
|
SortableContext,
|
||||||
sortableKeyboardCoordinates,
|
sortableKeyboardCoordinates,
|
||||||
|
@ -115,9 +117,8 @@ const ReactionEmoji: React.FC<{
|
||||||
ref={setNodeRef}
|
ref={setNodeRef}
|
||||||
style={style}
|
style={style}
|
||||||
{...attributes}
|
{...attributes}
|
||||||
{...listeners}
|
|
||||||
>
|
>
|
||||||
<span>
|
<span {...listeners}>
|
||||||
<Icon id='bars' icon={MenuIcon} className='handle' />
|
<Icon id='bars' icon={MenuIcon} className='handle' />
|
||||||
</span>
|
</span>
|
||||||
<div className='reaction_deck__emoji'>
|
<div className='reaction_deck__emoji'>
|
||||||
|
@ -259,6 +260,7 @@ export const ReactionDeck: React.FC<{
|
||||||
collisionDetection={closestCenter}
|
collisionDetection={closestCenter}
|
||||||
onDragStart={handleDragStart}
|
onDragStart={handleDragStart}
|
||||||
onDragEnd={handleDragEnd}
|
onDragEnd={handleDragEnd}
|
||||||
|
modifiers={[restrictToVerticalAxis]}
|
||||||
>
|
>
|
||||||
<SortableContext items={deck.toArray()} strategy={rectSortingStrategy}>
|
<SortableContext items={deck.toArray()} strategy={rectSortingStrategy}>
|
||||||
{deck.map((emoji: any, index) => (
|
{deck.map((emoji: any, index) => (
|
||||||
|
@ -274,16 +276,21 @@ export const ReactionDeck: React.FC<{
|
||||||
))}
|
))}
|
||||||
</SortableContext>
|
</SortableContext>
|
||||||
|
|
||||||
|
{createPortal(
|
||||||
<DragOverlay>
|
<DragOverlay>
|
||||||
{activeId ? (
|
{activeId ? (
|
||||||
|
<div style={{ position: 'fixed' }}>
|
||||||
<ReactionEmoji
|
<ReactionEmoji
|
||||||
emojiMap={emojiMap}
|
emojiMap={emojiMap}
|
||||||
emoji={activeEmoji.get('name')}
|
emoji={activeEmoji.get('name')}
|
||||||
index={-1}
|
index={-1}
|
||||||
overlay
|
overlay
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</DragOverlay>
|
</DragOverlay>,
|
||||||
|
document.body,
|
||||||
|
)}
|
||||||
</DndContext>
|
</DndContext>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@csstools/stylelint-formatter-github": "^1.0.0",
|
"@csstools/stylelint-formatter-github": "^1.0.0",
|
||||||
"@dnd-kit/core": "^6.1.0",
|
"@dnd-kit/core": "^6.1.0",
|
||||||
|
"@dnd-kit/modifiers": "9.0.0",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@formatjs/intl-pluralrules": "^5.4.4",
|
"@formatjs/intl-pluralrules": "^5.4.4",
|
||||||
|
|
14
yarn.lock
14
yarn.lock
|
@ -1710,6 +1710,19 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@dnd-kit/modifiers@npm:9.0.0":
|
||||||
|
version: 9.0.0
|
||||||
|
resolution: "@dnd-kit/modifiers@npm:9.0.0"
|
||||||
|
dependencies:
|
||||||
|
"@dnd-kit/utilities": "npm:^3.2.2"
|
||||||
|
tslib: "npm:^2.0.0"
|
||||||
|
peerDependencies:
|
||||||
|
"@dnd-kit/core": ^6.3.0
|
||||||
|
react: ">=16.8.0"
|
||||||
|
checksum: 10c0/ca8cc9da8296df10774d779c1611074dc327ccc3c49041c102111c98c7f2b2b73b6af5209c0eef6b2fe978ac63dc2a985efa87c85a8d786577304bd2e64cee1d
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@dnd-kit/sortable@npm:^10.0.0":
|
"@dnd-kit/sortable@npm:^10.0.0":
|
||||||
version: 10.0.0
|
version: 10.0.0
|
||||||
resolution: "@dnd-kit/sortable@npm:10.0.0"
|
resolution: "@dnd-kit/sortable@npm:10.0.0"
|
||||||
|
@ -2462,6 +2475,7 @@ __metadata:
|
||||||
dependencies:
|
dependencies:
|
||||||
"@csstools/stylelint-formatter-github": "npm:^1.0.0"
|
"@csstools/stylelint-formatter-github": "npm:^1.0.0"
|
||||||
"@dnd-kit/core": "npm:^6.1.0"
|
"@dnd-kit/core": "npm:^6.1.0"
|
||||||
|
"@dnd-kit/modifiers": "npm:9.0.0"
|
||||||
"@dnd-kit/sortable": "npm:^10.0.0"
|
"@dnd-kit/sortable": "npm:^10.0.0"
|
||||||
"@dnd-kit/utilities": "npm:^3.2.2"
|
"@dnd-kit/utilities": "npm:^3.2.2"
|
||||||
"@eslint/js": "npm:^9.23.0"
|
"@eslint/js": "npm:^9.23.0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue