File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -159,36 +159,44 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
159
159
screenY : screenY }
160
160
}
161
161
162
+ _setCoordinates ( element : HTMLElement , x : number , y :number ) {
163
+ let coordinates = this . _elCoordinates ( element )
164
+
165
+ coordinates . clientX += x || 0 ;
166
+ coordinates . clientY += y || 0 ;
167
+
168
+ return coordinates
169
+ }
170
+
162
171
protected _elNewCoordinates ( event : KeyboardEvent , element : HTMLElement ) {
163
172
const node = this . el . gridstackNode
164
173
const cellHeight = node . grid . getCellHeight ( ) * node . h
165
174
const cellWidth = node . grid . cellWidth ( )
166
175
const maxColumn = node . grid . opts . column
167
-
168
- let coordinates = this . _elCoordinates ( element )
176
+ let xCoord : number , yCoord : number
169
177
170
178
switch ( event . code ) {
171
179
case 'ArrowRight' :
172
180
if ( typeof ( maxColumn ) == 'number' && node . x === ( maxColumn - 1 ) ) { break }
173
181
174
- coordinates . clientX = coordinates . clientX + cellWidth + ( cellWidth / 2 )
182
+ xCoord = cellWidth
175
183
break
176
184
case 'ArrowLeft' :
177
185
if ( node . x === 0 ) { break }
178
186
179
- coordinates . clientX = coordinates . clientX - cellWidth - ( cellWidth / 2 )
187
+ xCoord = - cellWidth
180
188
break
181
189
case 'ArrowUp' :
182
190
if ( node . y === 0 ) { break }
183
191
184
- coordinates . clientY = coordinates . clientY - cellHeight
192
+ yCoord = - cellHeight
185
193
break
186
194
case 'ArrowDown' :
187
- coordinates . clientY = coordinates . clientY + cellHeight
195
+ yCoord = cellHeight
188
196
break
189
197
}
190
198
191
- return coordinates
199
+ return this . _setCoordinates ( element , xCoord , yCoord ) ;
192
200
}
193
201
194
202
protected _keyDown ( e : KeyboardEvent ) : void {
You can’t perform that action at this time.
0 commit comments