Skip to content

Commit c2a20ef

Browse files
committed
Ignore dragEnd coordinate when it differs too much from last drag event
Ref freeCodeCamp#265
1 parent de1c879 commit c2a20ef

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

assets/javascripts/views/layout/resizer.coffee

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ class app.views.Resizer extends app.View
4040

4141
onDrag: (event) =>
4242
return if @lastDrag and @lastDrag > Date.now() - 50
43+
value = event.pageX
4344
@lastDrag = Date.now()
44-
@resize(event.pageX, false)
45+
@lastDragValue = value
46+
@resize(value, false)
4547
return
4648

4749
onDragEnd: (event) =>
48-
@resize(event.pageX or (event.screenX - window.screenX), true)
50+
value = event.pageX or (event.screenX - window.screenX)
51+
if @lastDragValue and not (@lastDragValue - 5 < value < @lastDragValue + 5) # https://github.com/Thibaut/devdocs/issues/265
52+
value = @lastDragValue
53+
@resize(value, true)
4954
return

0 commit comments

Comments
 (0)