Skip to content

Commit

Permalink
Allow document to be overwritten for iframes #482
Browse files Browse the repository at this point in the history
  • Loading branch information
sekoyo committed May 11, 2022
1 parent 44a9169 commit b78c36c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-image-crop",
"version": "10.0.0",
"version": "10.0.1",
"description": "A responsive image cropping tool for React",
"repository": "https://github.com/DominicTobias/react-image-crop",
"main": "dist/ReactCrop.min.js",
Expand Down
13 changes: 7 additions & 6 deletions src/ReactCrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class ReactCrop extends PureComponent<ReactCropProps, ReactCropState> {
},
}

document = document
keysDown = new Set<string>()
docMoveBound = false
mouseDownOnCrop = false
Expand Down Expand Up @@ -167,9 +168,9 @@ class ReactCrop extends PureComponent<ReactCropProps, ReactCropState> {
return
}

document.addEventListener('pointermove', this.onDocPointerMove, DOC_MOVE_OPTS)
document.addEventListener('pointerup', this.onDocPointerDone, DOC_MOVE_OPTS)
document.addEventListener('pointercancel', this.onDocPointerDone, DOC_MOVE_OPTS)
this.document.addEventListener('pointermove', this.onDocPointerMove, DOC_MOVE_OPTS)
this.document.addEventListener('pointerup', this.onDocPointerDone, DOC_MOVE_OPTS)
this.document.addEventListener('pointercancel', this.onDocPointerDone, DOC_MOVE_OPTS)

this.docMoveBound = true
}
Expand All @@ -179,9 +180,9 @@ class ReactCrop extends PureComponent<ReactCropProps, ReactCropState> {
return
}

document.removeEventListener('pointermove', this.onDocPointerMove, DOC_MOVE_OPTS)
document.removeEventListener('pointerup', this.onDocPointerDone, DOC_MOVE_OPTS)
document.removeEventListener('pointercancel', this.onDocPointerDone, DOC_MOVE_OPTS)
this.document.removeEventListener('pointermove', this.onDocPointerMove, DOC_MOVE_OPTS)
this.document.removeEventListener('pointerup', this.onDocPointerDone, DOC_MOVE_OPTS)
this.document.removeEventListener('pointercancel', this.onDocPointerDone, DOC_MOVE_OPTS)

this.docMoveBound = false
}
Expand Down
2 changes: 1 addition & 1 deletion test/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ReactDOM from 'react-dom'
import React, { useState, useRef, useEffect, useCallback } from 'react'
import React, { useState, useRef } from 'react'
import ReactCrop, { centerCrop, makeAspectCrop, Crop, PixelCrop } from '../src'
import { cropPreview } from './cropPreview'
import { useDebounceEffect } from './useDebounceEffect'
Expand Down

0 comments on commit b78c36c

Please sign in to comment.