Skip to content

Commit

Permalink
Merge pull request #95 from cornerstonejs/dannyrb/blink-free-resize
Browse files Browse the repository at this point in the history
Dannyrb/blink free resize
  • Loading branch information
dannyrb authored Jul 3, 2020
2 parents bc6ee02 + fdba266 commit 241063d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 74 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dependencies": {
"classnames": "^2.2.6",
"date-fns": "^2.2.1",
"lodash.debounce": "^4.0.8",
"prop-types": "^15.7.2",
"react-resize-detector": "^4.2.1"
},
Expand Down
41 changes: 21 additions & 20 deletions src/CornerstoneViewport/CornerstoneViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ImageScrollbar from '../ImageScrollbar/ImageScrollbar.js';
import ViewportOverlay from '../ViewportOverlay/ViewportOverlay.js';
import LoadingIndicator from '../LoadingIndicator/LoadingIndicator.js';
import ViewportOrientationMarkers from '../ViewportOrientationMarkers/ViewportOrientationMarkers.js';
import windowResizeHandler from './windowResizeHandler.js';
import cornerstone from 'cornerstone-core';
import cornerstoneTools from 'cornerstone-tools';
import ReactResizeDetector from 'react-resize-detector/lib/index.js';
Expand Down Expand Up @@ -72,7 +71,12 @@ class CornerstoneViewport extends Component {
PropTypes.element,
PropTypes.func,
]),
resizeThrottleMs: PropTypes.number, // 0 to disable
/** false to enable automatic viewport resizing */
enableResizeDetector: PropTypes.bool,
/** rate at witch to apply resize mode's logic */
resizeRefreshRateMs: PropTypes.number,
/** whether resize refresh behavior is exhibited as throttle or debounce */
resizeRefreshMode: PropTypes.oneOf(['throttle', 'debounce']),
//
style: PropTypes.object,
className: PropTypes.string,
Expand All @@ -92,7 +96,9 @@ class CornerstoneViewport extends Component {
isOverlayVisible: true,
loadIndicatorDelay: 45,
loadingIndicatorComponent: LoadingIndicator,
resizeThrottleMs: 200,
enableResizeDetector: true,
resizeRefreshRateMs: 200,
resizeRefreshMode: 'debounce',
tools: [],
onNewImageDebounceTime: 0,
};
Expand Down Expand Up @@ -141,7 +147,6 @@ class CornerstoneViewport extends Component {
isStackPrefetchEnabled,
cornerstoneOptions,
imageIds,
resizeThrottleMs,
isPlaying,
frameRate,
} = this.props;
Expand All @@ -159,10 +164,6 @@ class CornerstoneViewport extends Component {
this._bindInternalElementEventListeners();
this._bindExternalEventListeners('element');

if (resizeThrottleMs) {
windowResizeHandler.enable(this.element, resizeThrottleMs);
}

// Only after `uuid` is set for enabledElement
this._setupLoadHandlers();

Expand Down Expand Up @@ -315,16 +316,14 @@ class CornerstoneViewport extends Component {
this._bindInternalElementEventListeners(clear);
this._bindExternalEventListeners('cornerstone', clear);
this._bindExternalEventListeners('element', clear);

this._setupLoadHandlers(clear);

if (this.props.isStackPrefetchEnabled) {
_enableStackPrefetching(this.element, clear);
}

cornerstoneTools.clearToolState(this.element, 'stackPrefetch');
cornerstoneTools.stopClip(this.element);
if (this.props.resizeThrottleMs) {
windowResizeHandler.disable(this.element);
}
cornerstone.disable(this.element);
}

Expand Down Expand Up @@ -740,14 +739,16 @@ class CornerstoneViewport extends Component {
style={this.props.style}
className={classNames('viewport-wrapper', this.props.className)}
>
<ReactResizeDetector
handleWidth
handleHeight
skipOnMount={true}
refreshMode={'throttle'}
refreshRate={this.props.resizeThrottleMs}
onResize={this.onResize}
/>
{this.props.enableResizeDetector && (
<ReactResizeDetector
handleWidth
handleHeight
skipOnMount={true}
refreshMode={this.props.resizeRefreshMode}
refreshRate={this.props.resizeRefreshRateMs}
onResize={this.onResize}
/>
)}
<div
className="viewport-element"
onContextMenu={e => e.preventDefault()}
Expand Down
54 changes: 0 additions & 54 deletions src/CornerstoneViewport/windowResizeHandler.js

This file was deleted.

0 comments on commit 241063d

Please sign in to comment.