Skip to content

Commit 5f96814

Browse files
authored
Merge pull request #132 from BHP-DevHub/master
Release v1.0.8
2 parents 3bc8bed + 0b5c067 commit 5f96814

File tree

4 files changed

+1259
-4
lines changed

4 files changed

+1259
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "react-timeline-9000",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Performance focused timeline for react",
55
"private": false,
66
"scripts": {
77
"build": "webpack --config webpack.prod.js",
88
"build_lib": "babel src --out-dir lib --ignore demo*,setupTests.js,*.test.js --copy-files --source-maps inline",
9-
"build_demo": "webpack --config webpack.dev.js",
9+
"build_demo": "webpack --config webpack.demo.prod.js",
1010
"start": "webpack-dev-server --open --config webpack.dev.js",
1111
"docs": "esdoc",
1212
"pretty": "prettier --write --tab-width 4 \"src/**/*.js\"",

src/timeline.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export default class Timeline extends React.Component {
123123
this.updateDimensions = this.updateDimensions.bind(this);
124124
this.grid_ref_callback = this.grid_ref_callback.bind(this);
125125
this.select_ref_callback = this.select_ref_callback.bind(this);
126+
this.throttledMouseMoveFunc = _.throttle(this.throttledMouseMoveFunc.bind(this), 20);
126127
this.mouseMoveFunc = this.mouseMoveFunc.bind(this);
127128
this.getCursor = this.getCursor.bind(this);
128129

@@ -135,6 +136,7 @@ export default class Timeline extends React.Component {
135136
componentDidMount() {
136137
window.addEventListener('resize', this.updateDimensions);
137138
}
139+
138140
componentWillReceiveProps(nextProps) {
139141
this.setTimeMap(nextProps.items, nextProps.startDate, nextProps.endDate);
140142
// @TODO
@@ -290,7 +292,11 @@ export default class Timeline extends React.Component {
290292
if (canDrag) {
291293
this._itemInteractable
292294
.draggable({
293-
enabled: true
295+
enabled: true,
296+
restrict: {
297+
restriction: `.${topDivClassId}`,
298+
elementRect: {left: 0, right: 1, top: 0, bottom: 1}
299+
}
294300
})
295301
.on('dragstart', e => {
296302
let selections = [];
@@ -729,7 +735,7 @@ export default class Timeline extends React.Component {
729735
* Event handler for onMouseMove.
730736
* Only calls back if a new snap time is reached
731737
*/
732-
mouseMoveFunc(e) {
738+
throttledMouseMoveFunc(e) {
733739
const {componentId} = this.props;
734740
const leftOffset = document.querySelector(`.rct9k-id-${componentId} .parent-div`).getBoundingClientRect().left;
735741
const cursorSnappedTime = getTimeAtPixel(
@@ -753,6 +759,11 @@ export default class Timeline extends React.Component {
753759
}
754760
}
755761

762+
mouseMoveFunc(e) {
763+
e.persist();
764+
this.throttledMouseMoveFunc(e);
765+
}
766+
756767
render() {
757768
const {onInteraction, groupOffset, timebarFormat, componentId, groupTitleRenderer} = this.props;
758769

webpack.demo.prod.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const webpack = require('webpack');
2+
const merge = require('webpack-merge');
3+
const common = require('./webpack.common.js');
4+
5+
const HtmlWebpackPlugin = require('html-webpack-plugin');
6+
7+
module.exports = merge(common, {
8+
entry: './src/demo_index.js',
9+
mode: 'production',
10+
devtool: 'source-map',
11+
plugins: [
12+
new HtmlWebpackPlugin({
13+
title: 'React Timeline 9000',
14+
template: 'src/demo.html',
15+
chunksSortMode: 'dependency',
16+
inject: 'body',
17+
minify: {
18+
removeComments: false,
19+
collapseWhitespace: false
20+
}
21+
}),
22+
new webpack.DefinePlugin({
23+
'process.env.NODE_ENV': JSON.stringify('production')
24+
})
25+
]
26+
});

0 commit comments

Comments
 (0)